5 ms·
I'm struggling to confirm that my intuition of why the compiler optimisation is faster than the naive switch expansion. Is it about the layout of where the ass
by AlexSW 2y ago
I'm struggling to confirm that my intuition of why the compiler optimisation is faster than the naive switch expansion.
Is it about the layout of where the assembly instructions end up, and spacing around them? Or the CPU pipelining working better? Or...?
- csjh 2y agodistributing the dispatch instructions lets the predictor pick up on specific patterns within the bytecode - for example, comparison instructions are probably followed by a conditional branch instruction
- AlexSW 2y agoAh of course! It's improving the branch target predictor. Makes sense, thanks!