4 ms·
Passing pointers is not significantly faster than passing offsets into a shared memory pool.
by mort96 3mo ago
Passing pointers is not significantly faster than passing offsets into a shared memory pool.
- menaerus 3mo agoSorry, what? Passing a pointer is a matter of wrapping the value into the CPU register. OTOH passing an offset into a shared memory is a write to main memory so several magnitudes slower.
- mort96 3mo agoPassing a pointer within one thread requires putting the pointer into a register. Passing a SHM offset within one process requires putting the offset into a register. Passing a pointer between threads requires going through the memory system and letting cache coherence algorithms sort out the data sharing between cores (with or without a futex lock/unlock depending on implementation). Passing a SHM offset between processes requires going through the memory system and letting cache coherence algorithms sort out the data sharing between cores (with or without a context switch to the kernel depending on implementation). It's not that different.