Repository navigation
Conversation
Author
|
Draft until I finish iterating on it and hand-read & hand-test the code |
Collect postorder entries once to obtain the node count and encode the same entries, avoiding repeated traversal and sharing-map work at the cost of temporary node storage. Written by OpenAI Codex.
tvolk131
force-pushed
the
perf/single-pass-program-encoding
branch
from
October 26, 2026 04:41
83442be to
61dd31f
Compare
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.
encode_programtraverses the encoding DAG once to count nodes and again to encode them, repeating sharing-map and traversal work. Collect the postorder entries once, write their count, then encode those same entries. Sharing rules, node order, and encoding bytes stay the same.This draft needs maintainer feedback on the CPU/memory tradeoff before adoption. The change retains an additional vector proportional to encoded node count.
Warmed release-mode serialization measurements on macOS ARM64 with Rust 1.99 (median of 33 paired thread-CPU samples):
Peak live requested heap during serialization increased from 621,072 to 1,059,336 bytes for the 2,048-leaf fixture, and from 9,901,072 to 16,913,416 bytes for 32,768 leaves (about 71% more). Allocation tracking starts after graph construction and a warm-up, includes the output buffer, and excludes allocator metadata and allocator-internal reallocation transients; these figures are not process RSS. Outputs were byte-identical for all fixtures. These synthetic measurements do not establish application-level impact.
Validation:
cargo test --locked --workspace --all-features(120 library tests, 14 sys tests, 2 doctests), including existing canonical-encoding, hidden-node, sharing, witness, and disconnect casescargo test --locked -p simplicity-lang --lib --no-default-features(64 tests)cargo +1.74.0 test --offline --locked -p simplicity-lang --lib --all-features(120 tests)cargo fmt --all -- --checkcargo clippy --locked --workspace --all-targets --all-features -- --deny warningsThis is independent of the stack-suffix optimization. A combined experiment reduced serialization CPU time by 31.5%, 33.6%, and 43.7% on the three timing fixtures, with the same measured peak requested heap as this change alone.
Written by OpenAI Codex.
Written with GPT 6.1 Sol on Extra High.