Skip Navigation

BB_C

@bb-c.programming.dev.ap.tdpl.io

1 Posts26 Comments0 Memberships

Joined September 2026

Collecting downvotes since before forums even had thank you's.

🌉 bridged from @BB_C@programming.dev by Tidepool

  • rust Rust Glancer 0.5.0: Matching rust-analyzer performance

    Restart, Restart, Restart

    I see the author is still pretending lspmux doesn't exist, which is ironically making his implementation look worse*, except for the restart benchmark itself 🙂

    memory vs. disk, memory vs. disk, memory vs. disk

    The author should try vmtouchfor a realistic** memory vs. disk-in-memory comparison, which shouldn't be a problem at all considering the specs of the devices the author is benchmarking on 😉 ——— * If I'm understanding the "server ready" numbers correctly. ** Using tmpfs or zram with any fs would work too obviously, but wouldn't match a realistic use-case. And we don't want to lose the excellent restart time 😉 on device reboot.

    2 0
  • rust The semver trick is not backwards compatible if you wait

    However, by not pinning to an exact version, your reexport may vary between installs despite the user using the same v1.0.1 version of your package, which may be unexpected and arguably violates the purpose of having immutable versions in crates.io.

    Re-exports exist outside of trick usage. num re-exports from num-* crates without exact version dependency restrictions, just to provide one major example.

    If v1.0.1 depends only on a subset of v2’s versions, then you still get a split between, say, [1.0.1, 2.1.0) and [2.1.0,).

    You can still release 1.1.x tracking 2.1.x, 1.2.x tracking 2.2.x, ..etc to satisfy your restrictions 😉 But as the sibling comment pointed out. People don't care about MINOR vs PATCH that much anyway. And the point of the trick is to smooth over a transition period, not keep the split forever.

    under the assumption the struct previously had nonpublic members of course

    Just for the sake of... exhaustiveness 😉, you can use #[non_exhaustive] on structs too.

    0 1
  • rust Mutex poisoning is not for everyone

    everyone else who’s been discussing this problem for years that it isn’t a problem.

    I haven't seen anyone else concede the performance talking point (under different banners), but proceeding to make this out to be a big issue. This includes this thread's OP which literally starts on-topic arguments with:

    How poisoning harms every single piece of code As discussed in too much detail above, (un)locking mutexes is cheap as long as they’re not contended, and when contended, they are at least cheap instruction wise. This is where poisoning mutexes get you.

    This is what makes your positioning weird. My replies here, starting with pointing out the lack of benchmarks of real-world use-cases, come from actually bothering to read OP, IN FULL.

    0 0
  • rust Mutex poisoning is not for everyone

    convenience, developer experience. Ergonomics basically.

    Can you point the notable relevant inconvenience, bad developer experience, and poor ergonomics developers are suffering from? Is it all caused by a lock() method returning a Result? Anything else?

    0 1
  • rust Mutex poisoning is not for everyone

    Well I would say this is not at all specific to the codebase

    I was talking about what a codebase would want a non-Result-returning lock() to look like (the panic message, or forcing abort, extra logging, signal handling...etc).

    since poisoning is so rarely relevant.

    Poisoning (as a negative) is only relevant if we are pretending it matters for performance. And you already conceded that this is not a part of the conversation as far as you're concerned. The "rarely relevant" (as in playing any operative role at all) is also pure conjecture, or if we want to be nicer, it's totally contextual and use-case dependant.

    then using an external dependency is a terrible solution.

    lock_api provides a generic interface so you can e.g. seamlessly swipe out primitives from parking_lot with primitives from spin, you know, the whole point behind generic programming! This is in no way comparable with leftpad. And I wasn't actually pointing to it as a solution (to the largely non-existing problem). I just wanted to point out that extension traits for synchronisation primitives already exist with wide usage in the ecosystem, since you seemed to not be aware. If you have an aversion to extension traits. Here is a trivial unit struct wrapper solution. You don't even need to change the Mutex type name or the lock() method name in your code.

     rust
    use std::ops::{Deref, DerefMut};
    use std::sync::Mutex as PMutex;
    
    #[repr(transparent)]
    struct Mutex<T>(PMutex<T>);
    
    impl<T> Deref for Mutex<T> {
        type Target = PMutex<T>;
        fn deref(&self) -> &Self::Target { &self.0 }
    }
    
    impl<T> DerefMut for Mutex<T> {
        fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 }
    }
    
    impl<T> Mutex<T> {
        fn new(v: T) -> Self {
            Self(PMutex::new(v))
        }
    
        fn lock<'a>(&'a self) ->  std::sync::MutexGuard<'a, T> {
            self.0.lock().expect("poisoned")
        }
    }
    
    fn main() {
        let m = Mutex::new(false);
        // oh look, it's a non-Result returning lock()
        *m.lock() = true;
        dbg!(*m.lock());
        // inner Mutex method API is still available via Deref/DerefMut
        *m.try_lock().unwrap() = false;
        dbg!(*m.lock());
    }

    And yea you could say “duh just write the extension trait in your utils module” but this is just not acknowledging the problem at all and just sidestepping it. That’s not helping anyone.

    What is the notable relevant problem. Can you state it plainly?

    0 1
  • rust Mutex poisoning is not for everyone

    Every non-trivial code-base already has a utils module (sometimes a whole crate even) containing, in part, extension traits (and sometimes macros) to make some usages of some types nicer, in a way that is specific to the codebase (even in this case, a codebase might want a debug or trace log message for example, alongside the panic). It's a part of the language for a reason. It provides full idiomacity. And this is not limited to (poisoned or otherwise) synchronization primitives. Talking about a method returning a Result like it's a big deal must be some sort of splitting-hairs maxxing. And btw, as it just happens, such traits actually already exist, in a crate that is well-known to the ecosystem.

    1 1
  • rust Mutex poisoning is not for everyone

    The real reason to not use poisoning mutexes is convenience and developer experience. The standard library should take such considerations heavily into account. A rare use case such as poisoning being required should not be the default for mutexes in the standard library.

    What does that even mean? The interface concerns are as trivial as it gets:

     rust
    #![feature(nonpoison_mutex)]
    #![feature(sync_nonpoison)]
    
    use std::sync::Mutex as PMutex;
    use std::sync::nonpoison::Mutex as NoPMutex;
    
    trait LockExt<'a> {
        type Guard;
        fn l(&'a self) -> Self::Guard;
    }
    
    impl<'a, T: 'a> LockExt<'a> for PMutex<T> {
        type Guard = std::sync::MutexGuard<'a, T>;
        fn l(&'a self) -> Self::Guard {
           self.lock().expect("non-poisoned") 
        }
    }
    
    impl<'a, T: 'a> LockExt<'a> for NoPMutex<T> {
        type Guard = std::sync::nonpoison::MutexGuard<'a, T>;
        fn l(&'a self) -> Self::Guard {
           self.lock() 
        }
    }
    
    fn main() {
        let m_p = PMutex::new(false);
        let m_no_p = NoPMutex::new(false);
        *m_p.l() = true;
        *m_no_p.l() = true;
        dbg!(*m_p.l());
        dbg!(*m_no_p.l());
    }

    This is basically is the one thing that shouldn't consume any mind tokens when it comes to synchronization primitive choice.

    0 1
  • rust Mutex poisoning is not for everyone

    1. The only real argument for not poisoning is "performance" (at the expense of safety). Provide a real-world use-case where you think poisoning is supposedly the bottleneck, and I will ^(try^ ^to)^ show you that it isn't. 2. I like how everyone is pretending writing your own extension trait is not a thing, where you can just add methods like panicking-lock() (with whatever short name you like), but also for backed-off lock (with try_lock() which is one atomic op and time-outs).

    0 2
  • rust A datetime library for Rust [jiff 1.0 released]

    it would be best

    The path of least resistance maybe. But as long as you get access to the timestamp (since epoch) from whatever detetime type used, you can do whatever you want. You can even use a third crate if you prefer. It's neither a big deal, nor does it take that much effort to do. And the timestamp is the only data you need on the wire to serialize for most use-cases, except for the few where you need to track time-zone changes alongside the timestamp.

    0 0
  • rust A datetime library for Rust [jiff 1.0 released]

    This is definitely an argument for a bigger standard library.

    bincode is not the best at anything, which is why people should have, and many indeed did move on from it many years ago. It's not particularly superfast (like speedy/borsh), doesn't cover zero-copy use-cases, isn't a standard (like cbor), and even serde support is gone in v2. So it's actually yet another example of why those things SHOULDN'T be in the standard library.

    1 0
  • rust Memory Safety Bugs in Rust Standard Library

    M$ ad talk now comes with LLM word diarrhea. Great! Nothing special is discovered or revealed here IMHO. The very first issue was independently found by security scans that don't come with a marketing budget. The ad itself admits other issues also have been independently reported by others. The str/pattern stuff validates the position that unicode-validation at construction then keeping everything byte-based wasn't a good choice. Explicit byte-view and char-view APIs would have been better. Otherwise, no harm from throwing free tokens at the rust compiler+std. They can still shove their now LLM-generated word diarrhea ad posts where they belong.

    10 0