Repository navigation
semantic: two quadratics made the build slower with every module, 22 min down to about 10 - #3684
Conversation
|
Caution Review failedThe pull request is closed. Walkthrough
Merge Risk:
|
sha=96a469647f3e7a04f778c040848aafa89d2d91c1
🤖 Salam AI reviewVerdict: ✅ Good to merge commit SummaryThis pull request optimizes semantic analysis and dead-code elimination by replacing several quadratic scans with watermarking, hash-set reachability, and a cheaper Persian-context prefilter, and adds a design note documenting build timings. The changes appear behavior-preserving, with the author reporting byte-identical generated C/H output (except build date) and unchanged semantic test results versus main. What changedThe PR reduces front-end build time by removing repeated work in semantic analysis and DCE: Review
TestsThe PR description reports all generated RisksLow. Future additions to the recognized Persian context words in
|
Why a big build is slow, measured with callgrind and per stage timestamps on the compiler building itself (88 modules, --backend=c):
Lexing and parsing are 0.5 s of a 22 minute build, so threading them gains nothing. Semantic analysis got slower with every loaded module (the same 5 definition package took 4 s early and 9 s late), which is the up to 10 s per package that was reported.
Causes and fixes:
Output is unchanged: all generated .c and .h files of the old and the new compiler are byte identical except the BUILD_DATE strings. semantic_test.salam gives 491 passed and 2 failed with the new compiler, the same 2 fail on main.
docs/design/BUILD_PARALLEL.md records the breakdown and what is left: caching analysed std packages between builds (the only way to make incremental rebuilds fast, high risk because sema tables are index based), pipelining codegen behind analysis, threaded per package sema (blocked by the g_sm_ globals). Wall times were taken on a machine under heavy load from other jobs, the front end and DCE numbers are the cleanest.
Summary by CodeRabbit
Performance
Bug Fixes
Documentation