4 ms·
This is interesting, thanks. That's a lot to read but I'm working my way through it. I read a whitepaper on value semantics: https://arxiv.org/pdf/2106.12678.p
by samsquire 4y ago
This is interesting, thanks. That's a lot to read but I'm working my way through it.
I read a whitepaper on value semantics: https://arxiv.org/pdf/2106.12678.pdf https://arxiv.org/pdf/2106.12678.pdf
I think it's promising.
I've been working on multithreaded code that passes references around. If you hold the reference, you have exclusive access for reading and writing the data at the reference. In theory you should only send values between threads when you need to pass exclusive access to a thread. At all other times, data is completely sharded between threads. The only reason to pass a reference around is to pass data between threads, similar to a queue but not quite. I deliberately avoid updating shared data structure such as a list that both threads are processing. Instead, each thread gets a shard.
I get 6,359,793 requests per second of passing reference around with this approach. Ideally each reference should correspond to a large amount of CPU work (at least 1 second), so that you shouldn't need to pass around references between threads that fast. This is 150 nanoseconds for a synchronization event, roughly 1.5 memory accesses.
- jcelerier 4y agoCheck out https://max0x7ba.github.io/atomic_queue/html/benchmarks.html https://max0x7ba.github.io/atomic_queue/html/benchmarks.html I'd be interested to see how the benchmarks there compare on your hardware - queues can be very performant