Marek Has Taken To Improving Mesa's GLSL Compiler Performance
Marek has been working to speed up the compilation time of the GL Shading Language (GLSL) compiler in Mesa by reducing malloc calls by about 63%. With less malloc calls, the compile times are better and there is less heap threashing.
Marek explained of the design change, "It's done by switching memory allocations in the GLSL compiler to my new linear allocator that allocates out of a fixed-sized buffer with a monotonically increasing offset. If more buffers are needed, it chains them. The new allocator is used in all places where short-lived allocations are used with a high number of malloc calls. The series also contains other improvements not related to the new allocator that also improve compile times."
This work complements the patches by Marek last month for using Jemalloc in Mesa, also in the name of greater performance.
Test results show that this latest patch series is almost fast enough to match the performance of using Mesa with jemalloc, already a big improvement over libc's malloc. But when switching to using jemalloc and these 15 new patches, the performance is even better. Shader-db was used as the test-case and compared to a 54 second out-of-the-box time right now, with this series plus jemalloc it drops down to 40 seconds!
The current 15 patches to rework the GLSL memroy allocation can be found on the Mesa mailing list and touch several hundred lines of code. However, this work probably won't be merged to Mesa Git in the next few days for making the next Mesa release -- there are some concerns on the Intel side with potential issues with their driver until they can better handle undefined memory, etc.