
Making MegaLinter Do Less Work
11 min read
This is the fourth and final post in a four-part series following a MegaLinter optimization investigation. The previous post ended with a deliberate constraint: keep the configured linter set intact and make that workload faster. That took the steady-state Jenkins pipeline from about three minutes and 39 seconds to 58 seconds.
At that point, I was willing to change the question.
Some of the remaining linters were doing work that did not provide useful evidence for this repository. The next step changed from making the same work cheaper to deciding which work belonged in the pipeline at all.
Then I let the pipeline do less
There was a clear optimization available after the pipeline reached 58 seconds. I had deliberately avoided it during the caching experiments because I wanted the 58-second result to preserve the configured linter set.
This repository is a small Bash project. It contains no infrastructure-as-code, so Checkov has little useful work to perform. Other enabled linters were similarly redundant or inapplicable to the repository. Once the caching experiment was complete, I disabled those tools and ran the pipeline again.
Build #16 completed in 37 seconds. Checkout consumed about 2.4 seconds, and the lint stage took approximately 33 seconds.
Build #17 used the same repository-specific linter configuration with SARIF output disabled. It completed in 36 seconds, with about 2.4 seconds spent in checkout and 31 seconds in the lint stage.
The one-second difference between those last two runs is too small for me to claim that disabling SARIF is worth exactly one second. The configuration change is known; ordinary run-to-run variation is still present. The useful comparison is that selecting the applicable workload moved the pipeline from 58 seconds into the high 30s, while removing SARIF output changed the observed result only slightly.
The progression now looked like this:
| Pipeline state | Runtime |
|---|---|
| Earlier steady-state Jenkins | ~3:39 |
| Optimized execution, same configured linter set | 0:58 |
| Repository-specific linters, SARIF enabled | 0:37 |
| Repository-specific linters, SARIF disabled | 0:36 |
Moving from 58 seconds to 37 removed another 21 seconds, or roughly 36 percent of the already-optimized runtime. Compared with the approximately 219-second steady-state pipeline from earlier in the investigation, build #16 was roughly 83 percent shorter. Build #17 moved the observed total down by one additional second.
Those improvements should not be treated as the same kind of optimization. Getting to 58 seconds was largely about eliminating repeated costs while preserving the linting functionality I started with. Images stayed nearby. Prepared vulnerability databases survived disposable containers. Compiled rules and other reusable scanner state remained available for later runs.
Getting from 58 seconds to 37 seconds involved changing the workload itself. Build #17 then changed the reporting behavior by disabling SARIF output.
Build #17 still performed the repository-security checks that were relevant to this project. Among the observed timings were:
| Linter | Runtime |
|---|---|
| Grype | 3.74s |
| Trivy | 3.66s |
| Kingfisher | 2.51s |
| Secretlint | 2.89s |
| Betterleaks | 1.77s |
| TruffleHog | 7.06s |
| CSpell | 8.39s |
| JSON v8r | 9.04s |
| YAML v8r | 12.39s |
Neither 37 nor 36 seconds establishes that the pipeline is fully optimized. A new profile exposes a new critical path, and there may be other useful improvements that I have not investigated.
What changed is that I was finally willing to remove work whose value did not justify its cost for this repository. “Disable the slow linter” can produce a smaller number quickly; in this case, I wanted to understand the execution costs first so I could distinguish inefficient useful work from work that did not belong in the repository.
Comparing the results with GitHub Actions
I also had recent GitHub Actions runs available for comparison. The last 15 MegaLinter executions were:
2:13, 2:27, 2:24, 2:24, 2:45,
2:42, 2:47, 2:40, 2:37, 2:58,
2:15, 2:26, 2:32, 2:26, 2:48Their mean was approximately 2:34, their median was about 2:32, and the observed range ran from 2:13 to 2:58.
The different Jenkins results answer different questions, so I prefer to keep all three visible:
| Execution | Runtime |
|---|---|
| Average GitHub Actions run | 2:34 |
| Warm Jenkins, same configured linter set | 0:58 |
| Repository-specific linters, SARIF enabled | 0:37 |
| Repository-specific linters, SARIF disabled | 0:36 |
The 58-second result remains the better comparison for what caching and persistence accomplished while preserving the configured linter set. It was approximately 62 percent shorter than the GitHub Actions average in this sample. Build #16 was approximately 76 percent shorter after the workload was also narrowed to checks appropriate for this repository.
None of those measurements establishes that Jenkins is intrinsically faster than GitHub Actions. The first post in this series began with exactly the opposite result: moving the workload to Jenkins initially increased runtime from roughly 170 seconds to about 660. The later numbers describe an execution environment after its persistence, caching, and workload-selection policies had changed.
Paying the polling penalty
My Jenkins Organization Folder scans the participating repositories once per minute. A commit can therefore wait anywhere from approximately zero to 60 seconds before Jenkins discovers it.
If commits arrive randomly relative to that polling cycle, the expected wait is about 30 seconds. Charging that delay against each observed execution produces:
| Jenkins workload | Execution | Expected end-to-end |
|---|---|---|
| Same configured linter set | 0:58 | 1:28 |
| Repository-specific, SARIF enabled | 0:37 | 1:07 |
| Repository-specific, SARIF disabled | 0:36 | 1:06 |
The average GitHub Actions run in the sample was 2:34. Even the 58-second same-linter-set result remained about 43 percent shorter after including the expected discovery delay.
The worst practical polling case adds almost the entire 60-second interval:
| Jenkins workload | Execution | Worst polling case |
|---|---|---|
| Same configured linter set | 0:58 | 1:58 |
| Repository-specific, SARIF enabled | 0:37 | 1:37 |
| Repository-specific, SARIF disabled | 0:36 | 1:36 |
The fastest of the 15 GitHub Actions runs was 2:13. Assuming a Jenkins worker is available when the repository scan discovers the change, even the worst polling case in these measurements remained below that fastest GitHub run.
That comparison has another caveat: a local queue under sufficient load would add delay that is not represented here. The polling and execution measurements are useful evidence about this environment, not a universal property of self-hosted CI.
The optimization hierarchy I ended up with
There are at least two ways to make CI faster. One is to perform useful work more efficiently. Another is to stop performing work that does not provide useful evidence.
The order matters.
I ended this investigation with something close to the following sequence:
- Decide whether the CI job needs to run at all.
- Avoid repeatedly acquiring large artifacts.
- Cache upstream distributions when doing so reduces useful acquisition cost.
- Preserve prepared scanner state whose lifecycle should exceed the container.
- Measure again and identify the new critical path.
- Remove checks that do not provide useful evidence for that repository.
- Remove report formats that are not consumed.
- Measure again.
The first post in this series exposed the first question. Draft pull requests that are still accumulating incremental work do not necessarily need the complete remote CI path after every push.
The Grype investigation exposed the middle of the list. A scanner can appear slow because its environment forces it to repeat expensive preparation rather than because the analysis itself is expensive.
The broader caching work showed that Grype was not unique. Trivy and Kingfisher provided strong evidence for the same lifecycle mismatch, while Syft, Checkov, and OSV-Scanner provided useful reminders that support for a cache does not establish its value for every workload.
Build #16 added the other half of the problem: even efficiently executed work can remain unnecessary work. Build #17 then tested a smaller reporting surface by disabling SARIF output.
Before Grype caching, a profile might contain:
Grype ~190s
Checkov ~55s
Groovy ~40s
Trivy ~30s
Kingfisher ~19s
Syft ~14sAfter the broader caching work, the landscape looked more like:
Checkov 32.08s
Groovy 23.73s
v8r 10-15s
cspell 8.91s
TruffleHog 7.12s
Trivy 4.12s
Grype 3.71s
Kingfisher 3.49s
Syft 3.09sAfter removing inapplicable and redundant linters, the profile changed again.
The optimization target moved every time.
Continuing to treat Grype as the performance problem after it reached four seconds would have meant optimizing yesterday’s bottleneck. Disabling Checkov before understanding the caching behavior would have produced a faster number while obscuring a reusable architectural lesson.
The measurements needed to lead the investigation.
What the four posts taught me
This series began because I consumed roughly 3,000 GitHub Actions minutes in five days and decided that I ought to understand where they were going.
The first lesson was that moving the workload onto infrastructure I owned did not make it faster. It initially increased runtime substantially. What Jenkins gave me was control over locality, persistence, and the lifetime of expensive state.
The second lesson came from Grype. A scanner that appeared to require three minutes to analyze a tiny Bash project was spending most of that time around the scan. Its prepared vulnerability database lived inside a disposable container, so I was repeatedly paying to create state that I immediately destroyed.
The third lesson was that Grype was not unique. Once I started looking at scanner state as something with its own lifecycle, Trivy and Kingfisher provided clear evidence of the same pattern. Syft, Checkov, and OSV-Scanner also reminded me that the existence of a cache does not prove that caching it will materially improve a particular workload.
The fourth lesson was that efficiently executed work can still be unnecessary work. Keeping the configured linter set intact took the steady-state Jenkins pipeline from roughly three minutes and 39 seconds to 58 seconds. Only after that experiment was complete did I remove linters that were inapplicable or redundant for this Bash repository. Build #16 completed in 37 seconds; build #17, with SARIF output disabled, completed in 36.
I do not take that as evidence that everyone should replace GitHub Actions with Jenkins, nor do I regard 36 seconds as evidence that this pipeline has reached some final optimum.
I take it as evidence that performance numbers deserve explanations.
A CI job is an accumulation of work: discovery, image acquisition, setup, database preparation, rule compilation, scanning, linting, reporting, and cleanup. The slowest visible tool may be performing expensive work that has little to do with the repository itself. A cache may preserve exactly the right state or state that the workload never uses. A platform migration may make a job faster, slower, or merely give us different opportunities to control the costs around it.
The useful question kept changing as the system changed.
At first it was, “Why am I spending so many GitHub Actions minutes?”
Then it became, “Why did moving this to Jenkins make it slower?”
Then, “Why does Grype need three minutes?”
Then, “What other useful knowledge am I paying to reconstruct every time?”
Finally, “Which of the remaining checks actually provide useful evidence for this repository?”
Those questions produced an architecture and an optimization process I intend to keep.
The result I intend to keep is the process that separated reusable state from disposable execution and useful evidence from work that did not belong in the repository. The 36-second number is one measurement from that process.
The containers remain disposable. The useful state survives them, and the work that does not belong in the repository no longer runs.