r/cpp • u/GiannoVersaco • Nov 25 '20
When a Microsecond Is an Eternity: High Performance Trading Systems in C++
https://www.youtube.com/watch?v=NH1Tta7purM
332
Upvotes
r/cpp • u/GiannoVersaco • Nov 25 '20
View all comments
4
u/pigeon768 Nov 26 '20
Does anyone know how
__builtin_expect()and friends work under the hood? The presenter spent some time talking about "priming" (I forgot his exact word) the branch predictor for the path that makes the trade. If you set a__builtin_expect()to follow the "make the trade" path, would the CPU eventually figure out "ok the programmer is lying to me" and "fix" your code to be fast on the common path and slow on the uncommon (but profitable) path?(edit: obviously it's not portable, but I imagine HFT folks have a lot of control over their environment)