News for hackers. Stuff that matters.
Re:Value-Oriented Programming by samsquire on Wednesday February 08, 2023 @09:09AM (#34708187)
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

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.

Re:Value-Oriented Programming by jcelerier on Wednesday February 08, 2023 @11:01AM (#34709916)
Check out 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