if (FALSE) { printf("can't happen\n"); }or even
asm("noop\n");to the body of a procedure cause a program to run measurably and consistently faster? I'll post the answer later today. (Or as much as I understand, anyway.)
Dave Herman's research blog.
if (FALSE) { printf("can't happen\n"); }or even
asm("noop\n");to the body of a procedure cause a program to run measurably and consistently faster? I'll post the answer later today. (Or as much as I understand, anyway.)
3 comments:
I vaguely recall reading something about the mozilla people making JS opcode implementations different sized so that the branch predictor had more meat to chew on. Maybe something to do with that? On the other hand, if I've already read about it then presumably it wouldn't have been a mystery.
Some kind of alignment thing? I can't think of how code would be affected by that, though.
A co-worker says "pipeline stall".
Adding the first line of code in that exact form will do nothing if optimization is enabled (it will be removed by dead code elimination).
The asm instruction will change instruction scheduling, register allocation and code layout, affecting the instruction cache, branch predictor and the out-of-order superscalar execution engine of your modern CPU (register renamer, reorder buffer etc.).
On microbenchmarks such small changes can create eg. 3x performance differences (by my own experiments)
Post a Comment