I am trying to instrument a rust binary to measure the hold and wait times for locks. I have a simple example with a single lock, but when I run the
nm test-rs | grep pthread, I get the following output:
As you see, it doesn't use the
pthread_unlock. Could you please help me with this issue?
The Rust standard library builds its on locks on top of OS primitives; for Linux, on top of futexes. You can see part of this in rust/futex_rwlock.rs at master · rust-lang/rust · GitHub, which uses inlined operations on two
AtomicU32 fields to implement the lock.
Since an uncontended lock operation is only a memory access, I'm afraid tracking locks won't be as simple as tracking function calls or syscalls.
That was done in Rust 1.62.0. So if you really want pthread mutexes, you could use Rust 1.61 or earlier, but that won't be a long-term solution...
Note that many Rust crates also use
parking_lot, which has its own locking mechanism, not using pthreads.
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.