Re:Lockless Algorithms for Mere Mortals
by danappelxx on Thursday July 30, 2020 @03:38AM
(#23995615)
But... give an example. When is shared-memory concurrency (with locks) faster?
[ Parent
| on HN ]
Re:Lockless Algorithms for Mere Mortals
by lalaland1125 on Thursday July 30, 2020 @04:06AM
(#23995747)
One good example would be writing a multi-threaded dictionary compression program. Dictionary compression is quite simple, you simply need to encode a bunch of strings to a series of integers and construct a dictionary that can perform the inverse mapping. The main trick is that you need a shared mutable dictionary to store the current list of string to integer mappings.
Doing this with an actor model would be tricky to the point of impossible. Sending a message to the common "dictionary" actor is much, much, much less efficient than just holding the corresponding sharded lock.