Repository navigation
perf(comp): memoize pure self-recursive defs on small word domains through a table (stacked on the compile-time PR) - #68
Draft
nicolas-abril wants to merge 3 commits into
Draft
nicolas-abril wants to merge 3 commits into
nicolas-abril wants to merge 3 commits into
Conversation
A def that calls itself twice or more along one path, on words, answering a
word (fib, binomials, change-making, tak) goes through a table keyed by its
arguments, filled on the first call. The table spans the Nat intervals
nv_book proves on a probe of the book (acc_def and def_fix off), a Bool's or
fieldless enum's constructors, or a window of the small values of a Nat no
self call raises (none passing a constant). The def becomes a wrapper whose
ops say miss, hit or outside; a call outside the table runs as before. One
pool of at most 2^20 entries (2^18 per def), result + 1 per entry, written
whole so racing threads store the same value. Defs a bang call reaches, or
that reach one, are left alone; on the device the ops say outside.
Tests: tests/run/memo_{window,offset,enum,deep,par,huge,bang,impure_array}.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 521f7a1)
The probe ran the integration's pipeline (clo_book, cf_book, and acc_def and def_fix kept off by an mprobe flag); this branch's compile_book runs file_book then nv_book, so the probe runs those two and the flag goes. BEND_MEMO is read through globalThis, which needs no Node types. Co-Authored-By: Claude Opus 5.5 <[email protected]>
compile_book's passes over the book before C is emitted (file_book and nv_book here) are one function, book_passes, which memo's probe runs too: a front pass added there (the closure pass, literal folding) reaches the probe without naming it, so memo's domains grow with what has landed (tak gets its table only once clo_book and cf_book run). The emitted C is the same. Co-Authored-By: Claude Opus 5.5 <[email protected]>
nicolas-abril
added a commit
that referenced
this pull request
Dec 1, 2026
…passes (#68) The passes over the book before C is emitted are one function, called by compile_book and by memo's probe, as in #68 (memo on main): memo's probe no longer names them. The C is unchanged (fib, coins, pascal, tak, the tar demo, memo_window, clo_elim and lit_fold byte-identical). 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, stacked on
opt/compile-speed: 3 commits of its own, with no integration history (headc15f0f83).It replaces #54.
Port notes
nv_book) to size its tables. Without them it tabled 3 of 8 osprey programs; with them 6 of 8. The token count includes the compile-time PR's.book_passes(), shared withcompile_book; it no longer names passes. When perf(comp): one specializer: a call copies its callee for the lambdas and constants it passes (replaces #31, #52, #2) #53 (closure pass) and the literal fold land, their passes go intobook_passes, and memo then tables tak too (8 of 8, confirmed in a scratch build).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
4ede335dperf(comp): memoize pure self-recursive defs on small word domainsc1a29284fix(port): memo's probe runs this branch's passes: file_book and nv_bookc15f0f83fix(port): memo's probe runs compile_book's passes through book_passes🤖 Generated with Claude Code