
Beyond Grype: Making Disposable MegaLinter Runs Fast
14 min read
This is the third post in a four-part series following a MegaLinter optimization investigation. The first post moved the workload from GitHub Actions to Jenkins; the second followed Grype from roughly three minutes to about four seconds. This post asks whether the persistence lesson from Grype generalizes to the rest of the pipeline.
By the time I reduced Grype from roughly three minutes to about four seconds, I was less interested in Grype as an isolated problem.
The more useful discovery was architectural.
MegaLinter was still running in disposable containers, exactly as I wanted. Each invocation started clean and disappeared when the lint job finished. The problem was that some of the tools inside those containers performed expensive work whose useful lifetime was much longer than the container that happened to perform it.
Grype made that mismatch visible. It prepared a large vulnerability database inside a container started with docker run --rm, used the database, and then lost the prepared state when Docker removed the container. Giving that database a lifecycle independent of the MegaLinter container reduced a representative Grype run from roughly 190 seconds to about four seconds.
Once that worked, another question followed naturally:
Which other MegaLinter scanners were rebuilding useful state inside a container that was going to disappear a few seconds later?
I did not want to respond by caching everything I could find. Temporary execution state is one of the reasons I like disposable containers in the first place. The goal was narrower: identify expensive filesystem state that was designed to be reused, preserve that state outside the container, and leave the execution environment disposable.
That distinction became the organizing principle for the next round of optimization.


