How to make Firefox builds 17% faster

Mozilla’s Firefox build pipeline just got a tidy little speed boost. With Bug 2027655 merged, the buildcache system can now wrap Firefox’s WebIDL Python code generation step — the same way it already intercepts compiler calls. Short story: a deterministic, early build step that used to run every clobber can now be cached. Who doesn’t like shaving seconds off a rebuild?
What changed under the hood
The patch is deceptively small. The py_action macro that runs Python build actions was extended so the Makefile can pass a command wrapper when MOZ_USING_BUILDCACHE is set. That means the WebIDL action is invoked as buildcache python3 -m mozbuild.action.webidl … instead of plain python3 -m mozbuild.action.webidl. Buildcache’s wrapper system then gets a chance to intercept and replay outputs rather than rerun the generator every time. The change is guarded by MOZ_USING_BUILDCACHE because ccache and sccache don’t offer the same arbitrary-command plugin mechanism.
The Lua trick
Buildcache’s Lua plugin system is the secret sauce. The webidl.lua wrapper matches the mozbuild.action.webidl invocation, enumerates inputs (the .webidl files and the Python codegen scripts via file-lists.json and codegen.json), and lists the generated outputs (headers, cpp, event files, state files). Using direct_mode — hashing inputs directly — the plugin can check the cache, replay artifacts, or run the generator and store the results. It’s straightforward, but satisfying: Python codegen treated like any other cacheable build action.
Numbers and why this matters
It has been reported that the author’s Linux ./mach build timings show buildcache cutting warm clobber builds down to 1m27s, and with the webidl.lua plugin down further to 1m12s — roughly a 17% improvement for that step and a huge delta versus uncached runs. These are not revolution-sized wins alone, but they’re proof of concept. The emotional bit? Developers get faster feedback. The practical bit? Other Python codegen steps could follow, and warm cached builds already put buildcache well ahead of the alternatives. Small change, big morale.
Sources: farre.se, Hacker News
Comments