Make Ubuntu Packages 90% Faster: A Tale of Recompilation and Allocators

2025-03-19
Make Ubuntu Packages 90% Faster: A Tale of Recompilation and Allocators

This post details how recompiling the jq source package used by Ubuntu resulted in a staggering 90% performance improvement. The author benchmarked against a 500MB GeoJSON file. Simply rebuilding the package yielded a small but noticeable speedup. Further optimizations included using clang with better flags (-O3, -flto, -DNDEBUG), which provided a 20% boost. Switching to the TCMalloc allocator improved performance by another 40%. Finally, using mimalloc, either dynamically loaded or integrated during the rebuild, resulted in the remarkable 90% speed increase. The recompiled jq with mimalloc is nearly twice as fast as the default Ubuntu package in various tests.