You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We use A scalable reader/writer scheme with optimistic retry and it works great until one thread writes faster than Thread.Spinwait(2) + write overhead. With 3 it is OK, with 1-2 a reader falls behind, and with 0 the reader cannot finish and has to retry a lot every read.
After writing completes the reader picks up, but the average performance is meaningless.
The solution is to read-lock on order version and not on any mutation. TryAddLast never changes the order of data and we already throw if a cursor sees order change.
Append/TryAddLast should write data without incrementing count, which should be volatile, and after data is written commit it by incrementing the counter (same as in DataSpreads StreamLog). Cursor cannot move past the counter and won't see the written data before commit.
For AppendOnly series readers should not use lock/versions at all.
Reader lock is only needed for ISeries.TryFind/TryGetValue. Since we throw on out of order data in cursors we only need volatile count.
Versions should mean order versions. Any mutation operation must detect if their application could change order and increment nextOrderVersion. Readers spin on the order versions (ISeries methods) or throw (cursors).
The text was updated successfully, but these errors were encountered:
We use A scalable reader/writer scheme with optimistic retry and it works great until one thread writes faster than
Thread.Spinwait(2) + write overhead
. With 3 it is OK, with 1-2 a reader falls behind, and with 0 the reader cannot finish and has to retry a lot every read.After writing completes the reader picks up, but the average performance is meaningless.
The solution is to read-lock on order version and not on any mutation.
TryAddLast
never changes the order of data and we already throw if a cursor sees order change.Append/TryAddLast
should write data without incrementing count, which should be volatile, and after data is written commit it by incrementing the counter (same as in DataSpreads StreamLog). Cursor cannot move past the counter and won't see the written data before commit.For AppendOnly series readers should not use lock/versions at all.
Reader lock is only needed for
ISeries.TryFind/TryGetValue
. Since we throw on out of order data in cursors we only need volatile count.Versions should mean order versions. Any mutation operation must detect if their application could change order and increment
nextOrderVersion
. Readers spin on the order versions (ISeries
methods) or throw (cursors).The text was updated successfully, but these errors were encountered: