Some googling showed me that over past 11 years people have noticed that Firefox uses optimized zip files. This inspired me to document thinking behind the optimized zip format I implemented in Firefox in the pre-pandemic 2010. I had a lot of fun writing this code, was surprised that I failed to blog about it.
Zip files seem to be designed for cheap appends. For every file inside a zip, there is a Local Header + optionally compressed file # contents.
Unfortunately reading files started from ending precludes readahead. It is also suboptimal to read files from zip in random order.
Since we already do PGO2 for Firefox builds, I added a ZipArchiveLogger for logging zip-entries being accessed to the Firefox profiling stage.
So for all cases where zip file access pattern matches one recorded during profiling phase Firefox can read the relevant resources in a single IO!
https://github.com/humphd/mozilla-central-old/blob/9d4d9f265e24e6358c067ae1e300c1ce3227a91d/config/optimizejars.py. This code later got subsumed into mozpack ↩︎