TL;DR: Process-based parallel scanning can create a memory spike, and Semgrep says its multicore update reduces that burden while delivering up to a 3x scan-time improvement within existing resource budgets, according to Semgrep. The operational lesson is broader: security scanning only scales when throughput and memory usage are engineered together, not treated as separate problems.
NHIMG editorial — based on content published by Semgrep: Multicore scanning for large codebases and why memory efficiency matters
By the numbers:
- Semgrep says the same job can see nearly a 58% difference in cost when using compute-optimized AWS EC2 C-series instances versus memory-optimized R or X-series instances.
Questions worth separating out
Q: How should security teams scale source code scanning without creating memory bottlenecks?
A: Treat scan scaling as a memory engineering problem, not only a compute problem.
Q: Why do large monorepos make code scanning less reliable in practice?
A: Large monorepos increase the amount of state a scanner must hold in memory, which can push process-based parallelism into duplication and garbage-collection overhead.
Q: What breaks when security scanning is parallelised without memory planning?
A: Memory usage grows faster than expected because each worker may duplicate analysis state, and the system can start thrashing before it uses all available CPU.
Practitioner guidance
- Instrument scan performance as a control metric Track completion time, peak resident memory, and retry frequency for security scans across representative repositories.
- Benchmark multicore settings against real monorepos Test shared-memory scanning against the largest repositories and heaviest rule sets in your environment before enabling it broadly.
- Set concurrency limits by memory profile Define worker and core limits based on observed memory ceilings, not just CPU availability.
What's in the full article
Semgrep's full article covers the implementation detail this post intentionally leaves for the source:
- Benchmark graphs showing CPU and memory behaviour across traditional parallelism and multicore execution
- Details of the OCaml 4 to OCaml 5 upgrade and why it enabled shared-memory concurrency
- Operational notes on the --x-parmap and --x-eio compatibility flags for teams testing the release
- Benchmark context from secDevLabs and the performance tradeoffs seen in large codebases
👉 Read Semgrep's analysis of multicore scanning for large codebases →
Multicore code scanning: what it means for DevOps teams?
Explore further
Performance is now a security control in large-scale code scanning. When scans are slow or memory-heavy, teams avoid running them, which creates a governance gap between security policy and actual developer behaviour. In practice, the control failure is not lack of rules but lack of adoption under operational pressure. For AppSec and DevOps teams, the real risk is optional scanning, not just inefficient scanning.
A question worth separating out:
Q: How can teams tell whether faster scans are actually improving security coverage?
A: Look for higher scan completion rates, fewer skipped pipeline runs, and stable resource use at the same repository volume. If speed improves but teams still avoid running scans or jobs fail under load, the programme has only shifted the bottleneck. Real improvement means faster scans and consistent adoption.
👉 Read our full editorial: Multicore code scanning shifts the memory and speed tradeoff