Full article: https://hftuniversity.com/post/seven-pieces-to-read-before-the-concurrency-interview Get full access to Low Latency Trading Insights at lucisqr.substack.com/subscribe
Audio and video play straight from the show's own hosting. PodSubs stores and serves no media.
Transcript
From the show. Tap a time to play from there.
SPEAKER_00This is our concurrency tag. Everything we have written on the subject, the piece is still in construction included, and it is ordered by date. Date order is worth nothing to you the week before an interview, so I read the lot again and ordered them by what an interviewer reaches for. Seven pieces, each one a case where something measurable contradicted the received wisdom, and each with the question it prepares you for. Here they are, all seven. 1. A Thursday at 2.47pm, a RISC dashboard showing a desk short 50,000 shares of NVIDIA
SPEAKER_00that nobody ordered out of a textbook Michael and Scott queue that had run clean for 6 months. It was signed off partly because x86 has strong memory ordering, so ABA could not bite. ABA is a lifetime bug wearing a memory model costume. $50,000. 2. 13 SecLock implementations, 3 platforms, 2 compilers, 2800 measured configurations. The compiler moved the numbers further than the implementation did, so a ranking taken under GCC does not survive a move to CLang on the same source.
SPEAKER_00Three, MFence retires in about one cycle on Intel Ice Lake and about four on AMD Zen 5. Same instruction, same source, four times the price depending who made your silicon. That is the instruction standing between your lock-free structure and incorrectness. Top 4 and my favorite. A rust queue advertised at 2.5 nanoseconds per push and pop, beating every C++ implementation by 8 times. Every benchmark behind it ran both ends on one thread, where the release store and the acquire load cost nothing.
SPEAKER_00Run properly on isolated cores, 668 cycles against 279 for the best C++ entry. Not 8 times ahead, 2.4 times behind. 5. Atomic Weight has been in the standard since C++20, lowering to a futex on the atomic zone storage word. No mutex and no predicate under a lock. Against the condition variable pattern every modern C++ guide still recommends, the round trip measured 23 times faster.
SPEAKER_006. A proposal from Mage to Michael, Paul McKenney, and Michael Wong adding a compare to STD atomic that is specified as a pure load. No benchmark in the paper, no cycle count. The argument is that comparing without loading keeps the other thread's value out of your scope entirely, where a plain load leaves it in a local for the next refactor to log or branch on. 7. Every pointer to an 8-byte aligned object has 3 spare low bits, and x86-64 uses 48 address bits, so the top 16 looks spare too.
SPEAKER_00Hanna Dusikova's paper was adopted for C++29 at BRNO in June. It standardizes one of three flavors, and the two a lock-free queue actually reaches for, the committee declined. Eight questions at the bottom, each mapped to a piece that answers it, and I name where the list is thin instead of hiding it. It leans hard on x86, and it has nothing on hazard pointers or RCU, which is one follow-up away from the story I opened with.
Link: https://www.amazon.com/Low-Latency-Trading-Insights-Measured/dp/B0HM1PQP2V “Pass small structs by value.” “A computed goto beats a switch.” “Turn the prefetchers off.” Thirteen rules every low-latency engineer...
Full article (accessible by Substack paid users) https://hftuniversity.com/post/a-hash-table-smaller-than-its-data-is-real-the-version-you-can-copy-is-not Get full access to Low Latency Trading Insights at...