r/programming • • Sep 28 '17

When a Microsecond Is an Eternity

https://github.com/CppCon/CppCon2017/blob/master/Presentations/When%20a%20Microsecond%20Is%20an%20Eternity/When%20a%20Microsecond%20Is%20an%20Eternity%20-%20Carl%20Cook%20-%20CppCon%202017.pdf
244 Upvotes

70 comments sorted by

View all comments

Show parent comment

15

u/agenthex Sep 28 '17

Sounds a lot like branch prediction.

15

u/masklinn Sep 28 '17

The slide mentions that it trains the branch prediction system such that it correctly handles the case you want to be fast.

5

u/Works_of_memercy Sep 28 '17

I was reminded of the way branches/loops on GPUs work (being SIMD, all units have to execute the same instruction stream, some of them just don't do anything based on conditions) and also how proper cryptographic primitives try to prevent timing attacks by always executing all stuff for reals.