Skip to content

perf(eval): skip the ReleaseSafe 0xAA fill of per-call scratch windows (O-064) - #83

Merged
BuddhiLW merged 1 commit into
stagingfrom
swarm/undefined-scratch
Oct 22, 2026
Merged

BuddhiLW merged 1 commit into
stagingfrom
swarm/undefined-scratch

Conversation

@BuddhiLW

Copy link
Copy Markdown
Owner

ReleaseSafe fills every = undefined local with 0xAA. The TreeWalk frame
locals, call args, arg locations, recur and constructor buffers
([MAX_LOCALS]Value, ~2 KB each) and the VM handler stack were memset on
every Clojure fn call: 19% of instructions in (reduce + (map * xs xs)).
Each user reads only a prefix it has just written, so the poison catches
nothing there. tree_walk.uninitScratch turns runtime safety off only for
the returned undefined in non-Debug modes; Debug keeps the poison.

User instructions, ReleaseSafe -Dwasm, taskset -c 2 (P-core), min of 2-3
runs, origin/staging -> this commit:
(println 1) startup 74.2M -> 66.9M -10%
40 seq_dot_1k 16.02G -> 13.15G -18%
41 seq_dot_100k 16.86G -> 13.74G -18%
13 lazy_chain -38%
19 multimethod_dispatch -35%
27 gc_large_heap -50%
45 byte_array_from_seq 2.66G -> 2.23G -16%
No cell of 01-39 regressed (worst +2.4%, one run, edn_roundtrip).

Card: CLJW-PERF-UNDEFINED-SCRATCH (20261022012239-6f906811).
Knowledge: 20261022011049-02b6329c.

…s (O-064)

ReleaseSafe fills every `= undefined` local with 0xAA. The TreeWalk frame
locals, call args, arg locations, recur and constructor buffers
([MAX_LOCALS]Value, ~2 KB each) and the VM handler stack were memset on
every Clojure fn call: 19% of instructions in (reduce + (map * xs xs)).
Each user reads only a prefix it has just written, so the poison catches
nothing there. `tree_walk.uninitScratch` turns runtime safety off only for
the returned undefined in non-Debug modes; Debug keeps the poison.

User instructions, ReleaseSafe -Dwasm, taskset -c 2 (P-core), min of 2-3
runs, origin/staging -> this commit:
  (println 1) startup        74.2M -> 66.9M   -10%
  40 seq_dot_1k             16.02G -> 13.15G   -18%
  41 seq_dot_100k           16.86G -> 13.74G   -18%
  13 lazy_chain                          -38%
  19 multimethod_dispatch                -35%
  27 gc_large_heap                       -50%
  45 byte_array_from_seq    2.66G  -> 2.23G   -16%
No cell of 01-39 regressed (worst +2.4%, one run, edn_roundtrip).

Card: CLJW-PERF-UNDEFINED-SCRATCH (20261022012239-6f906811).
Knowledge: 20261022011049-02b6329c.
@BuddhiLW
BuddhiLW merged commit d8c8721 into staging Oct 22, 2026
2 checks passed
BuddhiLW added a commit that referenced this pull request Oct 22, 2026
tree_walk.zig: #83 (O-064 uninitScratch) and this branch (O-080 safety-off
wrapper) both removed the ReleaseSafe 0xAA fill of the callMethod locals
buffer. Kept this branch's callMethodImpl/callMethodBody split, with the
buffer now taken from uninitScratch: one mechanism for per-call scratch.
O-080 ledger row updated to match. data/placement.yaml regenerated.

Smell-audited: 2: duplicate mechanism removed at merge, ledger amended
@BuddhiLW
BuddhiLW deleted the swarm/undefined-scratch branch October 22, 2026 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant