5 ms·
And some of your code is in the instruction cache and some isn't - meaning a sudden context[1] switch has to read a lot of code from memory which is slow(ish)
by octo_t 13y ago
And some of your code is in the instruction cache and some isn't - meaning a sudden context[1] switch has to read a lot of code from memory which is slow(ish)
[1] - not a thread switch (although that would be as costly), but an if-statement in a while loop changing from false to true etc.
- pbsd 13y agoUnless it's a friggin' gigantic loop, instruction cache miss will usually not be the issue there; branch misprediction will. Instruction cache misses are particularly problematic in codebases with many virtual function calls (or plain function pointers in C), which can't be easily prefetched ahead of time.
- deleted 13y ago[deleted]
- octo_t 13y agoI'll admit that branch misprediction will also screw you over, large event loops are sometimes large enough to escape the instruction cache (especially with function inlining)