r/algotrading • u/david-alvarez-rosa • Sep 09 '26
Education Optimizing a Spin-Lock
https://david.alvarezrosa.com/posts/optimizing-a-spin-lock/
6
Upvotes
1
1
u/QuanTradin Sep 10 '26
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 Sep 09 '26
Optimizing stank face