Skip to content

Speed up corpus benchmark: parallel parsing + GC off - #3

Merged
TomasVotruba merged 1 commit into
tv-corpus-benchmarkfrom
tv-corpus-benchmark-parallel
Sep 3, 2026
Merged

Speed up corpus benchmark: parallel parsing + GC off#3
TomasVotruba merged 1 commit into
tv-corpus-benchmarkfrom
tv-corpus-benchmark-parallel

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Stacked on #2. Makes the corpus benchmark parse across GOMAXPROCS workers and disables the GC for the short-lived run.

Why

Profiling the Laravel corpus (2966 files, 16.7 MB) showed parsing is ~95% of wall time (file IO is ~5%). Within parsing: the goyacc grammar engine is ~70%, the lexer ~20%, and allocation + GC ~20-35% (the parse allocates ~0.9 GB for a 16.7 MB corpus). Files are independent, so the two cheap wins are parallelism and skipping GC.

Change

  • Parse files across a worker pool sized to GOMAXPROCS (each worker reads + parses).
  • debug.SetGCPercent(-1) — the process is short-lived, so parse throughput matters more than steady-state memory.

Output format is unchanged (parsed N files in M ms).

Before / after

Same machine, same corpus, average of a few runs:

Machine Before (sequential, default GC) After (parallel + GC off) Speedup
4 cores (CI-like, GOMAXPROCS=4) ~1080 ms ~345 ms ~3.1x
24 cores ~1195 ms ~205 ms ~5.8x

Scaling tracks core count. Isolated contributions: GC off alone ~1.25x, parallelism the rest.

Note

This now measures max corpus throughput rather than pure per-file parser speed. That is the right trade for this repo's own benchmark; the cross-parser comparison repo intentionally keeps its Go parsers sequential for fairness.

@TomasVotruba
TomasVotruba merged commit a00534c into tv-corpus-benchmark Sep 3, 2026
@TomasVotruba
TomasVotruba deleted the tv-corpus-benchmark-parallel branch September 3, 2026 22:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant