Uh oh!
There was an error while loading. Please reload this page.
perf(ix): lazy, zero-copy anon env load for the Aiur check path - #445
Merged
Conversation
samuelburnhamforce-pushed
the
sb/aiur-lazy-env
branch
2 times, most recently
from
June 16, 2026 19:43
a845811 to
f27fbfbComparearthurpaulino
approved these changes
Jun 16, 2026
arthurpaulino
left a comment
Member
There was a problem hiding this comment.
Nice!
The "perf(aiur)" tripped me up a bit, but the patch looks good.
samuelburnham added a commit
that referenced
this pull request
Jun 17, 2026
Merge the Ix-compiler benchmark and a new Aiur execute/prove benchmark into one workflow (aiur-bench.yml). Per library env it runs 'ix compile' to a .ixe (compile-throughput metrics) then STARK-checks selected constants over that same .ixe via bench-typecheck (execute + prove metrics), combined into one bencher report. bench-typecheck loads the env lazily (Ixon.deEnvAnon, #445) so Mathlib statements check at ~10GB peak RSS instead of the ~100GB eager load. Constants are inline in the workflow matrix. Replaces compile.yml.
samuelburnham added a commit
that referenced
this pull request
Jun 17, 2026
Merge the Ix-compiler benchmark and a new Aiur execute/prove benchmark into one workflow (aiur-bench.yml). Per library env it runs 'ix compile' to a .ixe (compile-throughput metrics) then STARK-checks selected constants over that same .ixe via bench-typecheck (execute + prove metrics), combined into one bencher report. bench-typecheck loads the env lazily (Ixon.deEnvAnon, #445) so Mathlib statements check at ~10GB peak RSS instead of the ~100GB eager load. Constants are inline in the workflow matrix. Replaces compile.yml.
`ix check --ixe` deserialized the whole env eagerly: the Rust FFI materialized every constant and the Lean side built an object graph for all of them up front, even to check one lemma. On mathlib.ixe (2.97 GB) that was ~104 GB peak RSS / ~159 s just to load. Make the Lean `Ixon.Env` constants lazy and load them without copying: - `LazyConstant` is now an offset window `(buf, off, len)` into a shared backing buffer (+ optional materialized cache for the build path), parsed on demand. Only the checked closure is ever materialized. - New `rs_de_env_lazy` FFI: `Env::parse_lazy_index` walks the env once (reusing the existing parser, so every metadata variant incl. `CallSite` is handled) and returns per-const `(addr, offset, len)` windows into the buffer Lean passed in, plus `name -> addr` and per-`Defn` reducibility hints. No constant body is parsed or copied at load time. `deEnvAnon` reconstructs an `Env` of byte-window `LazyConstant`s over that same buffer. - This is anon-aligned with the circuit: binder metadata (the `ExprMetaArena`) is parsed-and-discarded, since the typecheck circuit only consumes anonymous constants, blobs, and the per-`Defn` hint. The CLI's `name -> addr` map is kept so targets can still be named. - Pure-Lean `getEnv`/`deEnv`/`rsDeEnv` keep their full-metadata behavior for round-trip and the non-check loaders; only the check path (`CheckCmd`) switches to `deEnvAnon`. Consumers updated for the lazy const type: closure walk, IOBuffer ingress (ships `rawBytes` windows directly), shard partitioning, decompile, and the compile/commit env builders. Measured on mathlib.ixe (same file, same target): 104.5 GB -> 4.5 GB peak RSS, 159 s -> 13.5 s, and the lazy run additionally typechecks the target rather than only resolving its address. Nothing in circuit changes: same closure bytes, same in-circuit blake3 verification, same proof.
samuelburnhamforce-pushed
the
sb/aiur-lazy-env
branch
from
June 17, 2026 15:45
f27fbfb to
061cfe4Comparesamuelburnham
enabled auto-merge (squash)
June 17, 2026 15:45
Uh oh!
There was an error while loading. Please reload this page.
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 freeto 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.
ix check --ixedeserialized the whole env eagerly: the Rust FFI materialized every constant and the Lean side built an object graph for all of them up front, even to check one lemma. On mathlib.ixe (2.97 GB) that was ~104 GB peak RSS / ~159 s just to load.Make the Lean
Ixon.Envconstants lazy and load them without copying:LazyConstantis now an offset window(buf, off, len)into a shared backing buffer (+ optional materialized cache for the build path), parsed on demand. Only the checked closure is ever materialized.rs_de_env_lazyFFI:Env::parse_lazy_indexwalks the env once (reusing the existing parser, so every metadata variant incl.CallSiteis handled) and returns per-const(addr, offset, len)windows into the buffer Lean passed in, plusname -> addrand per-Defnreducibility hints. No constant body is parsed or copied at load time.deEnvAnonreconstructs anEnvof byte-windowLazyConstants over that same buffer.ExprMetaArena) is parsed-and-discarded, since the typecheck circuit only consumes anonymous constants, blobs, and the per-Defnhint. The CLI'sname -> addrmap is kept so targets can still be named.getEnv/deEnv/rsDeEnvkeep their full-metadata behavior for round-trip and the non-check loaders; only the check path (CheckCmd) switches todeEnvAnon.Consumers updated for the lazy const type: closure walk, IOBuffer ingress (ships
rawByteswindows directly), shard partitioning, decompile, and the compile/commit env builders.Measured on mathlib.ixe (same file, same target): 104.5 GB -> 4.5 GB peak RSS, 159 s -> 13.5 s. Nothing in circuit changes: same closure bytes, same in-circuit blake3 verification, same proof.
Builds on the Rust kernel lazy deserialization from #415