Repository navigation
Skip the assigned-variable walk when a Lambda arena holds no assignment - #94
Merged
Merged
Conversation
ec8f971 (evaluate the arguments of an inlined call left to right) asks which variables a term assigns in four places: once per run of the alias and let simplification passes, once before compiling to JS, and once for every inlined call. Each answer walked the whole term and built a hash set, and the set is almost always empty: only a mutable variable that is kept local produces an assignment. The arena now records whether an assignment node was ever added to it, and `arena_assigned_variables` returns the empty set without walking when none was. With an assignment anywhere in the arena the walk runs as before, so the result is the same in every case. Clean build of a 3,735-module application, one-codegen-unit release build, the same binary with and without the walk, alternating pairs, 1 worker: 83.82 -> 83.33 G instructions (paired -0.49 +- 0.14, n=8). The 3,980 generated files are identical. Co-authored-by: Jaap Frolich <jfrolich@gmail.com> Session: https://jakes-mac-mini.tail23a77e.ts.net:8443/session/os-01a1c9fa-0c5d-7912-a93b-3e7f38e53547 Signed-off-by: open-session-submodule[bot] <341020755+open-session-submodule[bot]@users.noreply.github.com>
Co-authored-by: Jaap Frolich <jfrolich@gmail.com> Session: https://jakes-mac-mini.tail23a77e.ts.net:8443/session/os-01a1c9fa-0c5d-7912-a93b-3e7f38e53547 Signed-off-by: open-session-submodule[bot] <341020755+open-session-submodule[bot]@users.noreply.github.com>
jfrolich
force-pushed
the
skip-assigned-variable-walk
branch
from
November 11, 2026 17:23
da0a390 to
f0e9d04
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.
What
arena_assigned_variablesreturns the empty set without walking the term when the Lambda arena holds no assignment node.Why
ec8f971 (the port of "Evaluate the arguments of an inlined call left to right") needs to know which variables a term assigns, so that reads of them keep their order. It asks in four places: once per run of the alias simplification pass, once per run of the let simplification pass, once before compiling to JS, and once for every inlined call. Each answer walked the whole term recursively and built a hash set.
The set is almost always empty: only a mutable variable that is kept local produces an assignment, and the comment at the call site in
lam_pass_remove_alias.rsalready says so. In a profile of a 3,735-module application the walk was 0.43% of CPU, and the commit as a whole raised a clean build by about 0.5 G instructions.How
LamArenarecords inpushwhether anAssignnode was ever added (may_assign). With none, no term of the arena can assign anything, so the answer is the empty set. With one anywhere in the arena, the walk runs exactly as before. The result is therefore the same in every case.Measurements
Clean build of a 3,735-module application, release build with one codegen unit, the same binary with and without the walk, alternating pairs, retired instructions from
/usr/bin/time -l:The 3,980 generated files are byte-identical.
Tests
an_arena_without_assignments_needs_no_walk_for_assigned_variablesinlambda::arena: an arena without assignments answers empty; adding one brings the walk back for terms that contain it and terms that do not; a cloned arena keeps the answer.Started by Jaap Frolich in this Assistant session