top | item 42676475

(no title)

dannymi | 1 year ago

I would suggest you read the source code of Mutex <https://doc.rust-lang.org/src/std/sync/mutex.rs.html#178-182> and then of UnsafeCell <https://doc.rust-lang.org/std/cell/struct.UnsafeCell.html>.

So, the layout of Mutex<T> is the same as T and then some lock (well, obviously).

>Rust introduces an extra layer of pointer indirection with Mutex, which can hurt performance significantly with cache misses.

Why would there be an extra pointer dereference? There isn't.

discuss

order

sesm|1 year ago

Thanks for the explanation!