Repository navigation
defk-o08.3: the copy analysis asks each arm's reads in one pass - #69
Merged
Merged
Conversation
… measured again against its budget DEFK_COMPILE_TIME=<file> makes every module compile once more in a fresh process and log its microseconds and reductions; dev/compile_time.exs compares interleaved rounds of two checkouts. The old method timed a first compile, which under mix dump_c waited ~1 s for the compiler's own modules, and a second compile in the same process varied twofold. Measured again: the symbolic-bounds chain +13.4% time / +20.8% reductions, the refactors after it +13.5% / +7.3%, together ~29% past the compiler before step 1 (docs/performance.md 6.38, ADR-0007's cost note).
Copies.nested/3 asked arm?/2, taken/2 and reads_outside/2 for every nested block: five walks of the statement, taken/2 quadratic. arm_reads/2 gives the same answer in three linear walks, rebuilding only the path to the arm; the old functions stay as the spec, and a property test compares the two on every subterm of generated statements. C byte-identical; the compiler's work -9.2% (reductions), time -9.6%, +17.6% of the work before the symbolic-bounds chain (docs/performance.md 6.39).
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.
Merge #68 first. This branch builds on
defk-o08.2/compile-time(the timing harness it was measured with). Until #68 merges, this PR shows that commit too.What changed
Copies.nested/3asked three questions for every block nested in a statement:arm?/2,taken/2andreads_outside/2. Together they made five walks of the whole statement, andtaken/2was quadratic, because it calledholds_arm?/2(a walk of the arms) on every node. This was the largest single cost in the compiler: about 10% of the time.Copies.arm_reads/2gives the same answer in three linear walks:cut/2rebuilds only the path to the arm. It mirrorsMacro.prewalk's descent, and on the way back it cuts eachif,condandcaseasother_arms_out/2does.reads/1reads what is left.test/copies_test.exshas a property test that comparesarm_reads/2witharm?plusreads_outside(taken(...))on every subterm of generated statements. The statements containif,cond,case, matches and blocks, and they use few names, so that a node often appears twice.docs/performance.md6.39, and ADR-0007's cost note.Results
mix dump_cis byte-identical for all 108 modules. The only difference is the known path-hasheddefk:loopkey inDefk.ReportTest.Gen.c.mainplus the harness:SatEx.Kernels);SatEx.Kernels);SatEx.Kernels: −8.4 M reductions, −86 ms.SatEx.Kernels), down from +29.5%. That is still above the 15% ceiling; two follow-up cuts are ticketed.Provisional: the laptop was on battery, with no quiet-machine check.
How it was checked
mix cion the laptop (macOS) passed: 2302 tests, Credo found no issues, Dialyzer reported 0 errors.A mutation run: with the condition of an
ifkept instead of cut, the property test and the example test both failed. The line was then restored.The byte-identical
mix dump_cgate, against an untouchedmaincheckout.Touches a promised surface? No. No
CHANGELOG.mdentry.Touches
test/stability/? No.