eclipse-zenoh / zenoh

zenoh unifies data in motion, data in-use, data at rest and computations. It carefully blends traditional pub/sub with geo-distributed storages, queries and computations, while retaining a level of time and space efficiency that is well beyond any of the mainstream stacks.
https://zenoh.io
Other
1.44k stars 151 forks source link

Stable SHM: atomic performance considerations #1057

Open yellowhatter opened 4 months ago

yellowhatter commented 4 months ago

Describe the feature

SHM subsystem uses atomics for both buffer headers (u32) and buffer watchdog(u64).

On some platforms 64-bit atomics are not supported (and I guess that library emulates them with Mutex introducing a huge performance drop in contended scenario), and some platforms support even u128 atomics.

I think for the future plan we need to investigate on this issue and our target platforms and maybe use a platform-dependent atomic sizes in SHM. The codebase more or less intends this future improvement.

I place this issue just to highlight this future milestone.

yellowhatter commented 4 months ago

@Mallets @YuanYuYuan FYI

Mallets commented 4 months ago

Emulation of Atomics is more a C++ thing than a Rust one. If a platform does not support 64-bit atomics, then it won't be available in Rust. See https://doc.rust-lang.org/std/sync/atomic/#portability.

yellowhatter commented 4 months ago

Emulation of Atomics is more a C++ thing than a Rust one. If a platform does not support 64-bit atomics, then it won't be available in Rust. See https://doc.rust-lang.org/std/sync/atomic/#portability.

Then this is even worse - we won't compile if there is no atomic u64 while we could have conditionally replaced it with u32....

And the doc says that on some platforms there is a performance penalty for CAS etc - this is also a thing to pay attention to while optimizing critical watchdog processing mechanism after 1.0.0