|
|
|
|
|
by IndoorPatio
1020 days ago
|
|
In my experience Left-Write is the clear place to start. It's general purpose and fast for reads. Only if that is unsuitable (eg memory usage) does one design a custom data structure. There's a Rust lib implementation with links to more resources: https://docs.rs/left-right/latest/left_right/ |
|
Still, I think the left-right crate could benefit from one optimization I came up with. This is what the lib says in the docs:
> When WriteHandle::publish is called, the writer, atomically swaps the reader pointer to point to the other T. It then waits for the epochs of all current readers to change, and then replays the operational log to bring the stale copy up to date.
I think the lib could postpone the log replaying until the next publish. Chances are all readers will have the new epoch by than = the writer thread won't have to wait at all.