Repository navigation
perf(comp): compile time: Nat ranges proved once (nv_book), match literals and arm walks memoized, emission memos that drop dead terms - #63
Draft
nicolas-abril wants to merge 9 commits into
Draft
nicolas-abril wants to merge 9 commits into
nicolas-abril wants to merge 9 commits into
Conversation
Co-Authored-By: Claude Opus 5.5 <[email protected]> (cherry picked from commit e8c3983)
…p exit Co-Authored-By: Claude Opus 5.5 <[email protected]> (cherry picked from commit 58c43ab)
Co-Authored-By: Claude Opus 5.5 <[email protected]> (cherry picked from commit a4e15f8)
…unds widen after 64 walks (isqrt's Newton step keeps y >= 1) Co-Authored-By: Claude Opus 5.5 <[email protected]> (cherry picked from commit 2f4091e)
Co-Authored-By: Claude Opus 5.5 <[email protected]> (cherry picked from commit 0629568)
…self builds back's node once A unit's emission builds terms (instantiated arms, arm_self's copies) that die with it, but the memos keyed by a term kept every one: perceus/deriv's literal matches left 5.5M entries in ground alone, 2.1 GB live after c_units on main and over the 4,096 MB cap on opt/integration. The memos whose values hold terms or probes (opens, teles, cols, etas, consts' inner maps) are WeakMaps; the pure ones (ground, uses, spines) stay Maps, cleared when a unit starts with over MEMO_MAX = 2^18 entries (as WeakMaps their millions of entries slowed every GC: awfy/json's emit 1.9 s -> 3.2 s). arm_self compared each node with a fresh back(ps), a chain of 32+ nodes per call; it is built once per length of ps. The emitted C is byte-identical. Co-Authored-By: Claude Opus 5.5 <[email protected]> (cherry picked from commit a99025b)
…very round c_units emits every unit 3-4 times, and each emit_match walked its arms again with a fresh self: mat_lits compared each U32 level's default with the one it covers (term_same of two instantiated arms), arm_self walked every arm for nodes it re-forms, and path_use counted self's uses down every path. mat_lits now keeps which levels answer for themselves with the match (FL.wlits); arm_self keeps a walk that re-formed nothing with the arm (FL.selfs), with the node back built for each length of ps it compared against, and a later call whose back builds the same nodes takes it; an arm with no self in it keeps its path test (FL.dead), and the test is a boolean that stops at the first answer (path_pos, for path_use > 0). clo_refs walks an array's items by index, without a key array. Same C on the 2,129-program corpus; perceus/deriv emits in 11.9 s instead of 15.4 s. Co-Authored-By: Claude Opus 5.5 <[email protected]> (cherry picked from commit 0a54062)
… moved The relation rounds walk every def until no walk changes a relation; a walk in them reads no state but the def's own relations (E is all top, calls answer top, and the relations it sets for a callee are recomputed from all its sites whenever one changes). A def whose relations are the ones its last walk started from is not walked again, which drops most of the round that only confirms. Same C on the 2,129-program corpus. Co-Authored-By: Claude Opus 5.5 <[email protected]> (cherry picked from commit 97674ad)
…apped nv_step reads the divided Var's index through a cast, nv_rel_fix types its pairs before the filter, and mat_lits' plan is a LitPlan, so its rows are not implicitly any. The selfs field is wrapped under 80 columns. Co-Authored-By: Claude Opus 5.5 <[email protected]>
nicolas-abril
added a commit
that referenced
this pull request
Dec 1, 2026
…33, #34, #36, #39, #44, #61-#68): record their heads Each is a port onto main of integration's own branch, its content already here (integration keeps the original commits; the ports add type fixes, line wraps, moved pieces and #68's book_passes, applied in the previous commit). Groups: #61 (#9 #11 #15 #32 #41 #42), #62 (#26 #56), #63 (#48 #50 and compile-time), #64 (#19 #20 #45), #67 (#55 #58), #68 (#54); par-defer (#43) is now part of #34, lazy-startup's parts are in #16 and #34. This merge records their heads (-s ours: no content change). Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
On main (
6180be5b)This PR is a port onto main, on
main: 9 commits of its own, with no integration history (head2909a635).It replaces #48, #50.
Port notes
nv_book) and perf(comp): memos keyed by a term no longer keep the terms each unit's emission drops #50 (compile-mem). Nat bounds: drop 2^48 limit and zero-divisor tests that static bounds rule out #48 uses 11 lines of compile-time's code and perf(comp): memos keyed by a term no longer keep the terms each unit's emission drops #50 is its follow-up.69ade704(it only touches the closure pass, literal fold and c-calls code) and70568cd6(it only rewriteslt_any).val_hold,val_to,emit_spin,emit_native,emit_intr,emit_ctr,emit_expr,emit_match,compile_book); its hooks for other branches (index bounds, lanes, forced inlining) are left out.type LitPlan).Checks
run/array_slabfails on main too).ttok -m gpt-3.5-turbo) over main, which is at 65,989 of the 66,000 cap.Performance was measured on integration when this change merged there (see the original description or the replaced PRs); it has not been re-measured on main.
What it does
The change of the PRs it replaces, ported together:
Their descriptions hold the design and the measurements.
Commits
a6ee4314WIP: Nat range analysis and sunk sum testsfcb5f02bNat bounds: range analysis drops limit tests, sunk sums tested at loop exitc3bdea6aNat bounds: sunk sums off by default (collatz level overall)2f884449Nat bounds: a parameter a loop steps down goes to 0 at once; other bounds widen after 64 walks (isqrt's Newton step keeps y >= 1)7c7195daNat bounds: drop the sunk-sum tests (kept on opt/nat-tests-sink)420b991dperf(comp): memos keyed by a term no longer keep a unit's terms; arm_self builds back's node oncea9965e24perf(comp): a match's arms are walked for re-formed nodes once, not every roundffcd2688perf(comp): nv_book's relation rounds walk only a def whose relations moved2909a635fix(port): the Nat bounds and the arm walk memos type-check; selfs wrapped🤖 Generated with Claude Code