jonhoo / left-right

A lock-free, read-optimized, concurrency primitive.
Apache License 2.0
1.95k stars 94 forks source link

More than two internal maps? #52

Closed antonmarsden closed 4 years ago

antonmarsden commented 4 years ago

This isn't really an issue, more of a question. Have you considered using more than 2 internal maps in a "ring"? The benefit would be less waiting on readers, but the down sides are more memory use (but memory is cheap!) and more complicated logic to apply changes to each map in the ring.

jonhoo commented 4 years ago

I considered using three initially, but realized that it doesn't really buy you that much. Readers already do not ever wait, so the additional map would only really help the writer. It also means that the writer no longer has a way to make readers see updated values, so consistency would suffer.

Is there a particular use-case you had in mind?

antonmarsden commented 4 years ago

The main scenario I was thinking about was readers doing longer "transactions" with the map, and what impact that might have. Purely theoretical though, no practical use cases in mind :)