Speed up corpus benchmark: parallel parsing + GC off - #3
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #2. Makes the corpus benchmark parse across
GOMAXPROCSworkers 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
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:
GOMAXPROCS=4)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.