3 ms·
When I first read this, I thought how come no one thought of this before? It feels like common sense. Dumb question (potentially): will this make code that is
by keyle 8y ago
When I first read this, I thought how come no one thought of this before? It feels like common sense.
Dumb question (potentially): will this make code that is not inlined, calling a function many times, often, run a lot slower?
- Mordak 8y agoIt depends on the function. Many things will contribute. If your CPU can keep the cookie in cache then loading it repeatedly will relatively fast compared to hitting main memory. If your branch predictor can figure out the jmp over the int3 instructions quickly then that will also be fast. If the function is very short then the retguard stuff will add relatively more instructions to the function so will have a larger impact than if the function was long, etc. I found that the runtime overhead was about 2% on average, but there are many factors that contribute.
- Annatar 8y agoYes. Any extra instructions will slow things down. The number of times the code runs will be the amplifying factor.