3 ms·
The massive Python regression is because of a missing, trivial compiler optimization, one already implemented but just not applied when you compile to push fram
by moloch-hai 4y ago
The massive Python regression is because of a missing, trivial compiler optimization, one already implemented but just not applied when you compile to push frame pointers.
There is no actual need for the compiler to maintain a frame-pointer register, or to access stack frame values relative to it. When you compile without, the compiler does fine. The compiler could generate that instruction to push a copy of the stack pointer, and do nothing else different from when working without, as it is doing now, except to add a larger value to the stack pointer before returning.
That said, who runs Python if they are bothered about performance?
- gpderetta 4y agoSo for what I can tell, there are two issues: - one less register means more spills, so more instructions and more read/writes from the stack. - when frame pointer is enabled, gcc uses offsets from the framepointer to address stack slots instead of offsets from the stack pointer. For the python interpreter function this means larger offsets, but it is not always necessarily the case. The right thing would be for the compiler to always issue the shorter instruction (i.e. an offset from rbp or rsp). edit: rbp offsets are normally negative, so yes, they are usually larger than positive rsp offsets.
- moloch-hai 4y agoOf course you don't need to devote a register, so no spills. Using the frame pointer for access to local stack spills is a pessimization the compiler should stop doing, regardless of the build mode.