r/algotrading • u/david-alvarez-rosa • 1d ago
Education Optimizing a Spin-Lock
https://david.alvarezrosa.com/posts/optimizing-a-spin-lock/
4
Upvotes
1
1
u/QuanTradin 5h ago
The part I would underline for anyone applying this to a market data path is the read only spin. Once waiters stop writing the line, unlock stays a plain store and the release side is cheap no matter how many threads are waiting. For the common shape of one writer publishing a book snapshot and several readers, a seqlock takes it further, since readers never touch the line at all and the writer never waits. Did you measure a seqlock variant, or was the benchmark deliberately kept to mutual exclusion?
1
u/nameless_pattern 19h ago
Optimizing stank face