|
114 | 114 | | O-051 | `runtime/collection/map.zig` (`arrayMapKeywordSlot` helper + `get`/`contains` keyword fast path) (ADR-0165/ADR-0148; destructure, gc_large_heap) | An `.array_map` `get`/`contains` scanned every entry through `keyEq`→`equal.eqConsult`→`isSimpleEqKey`×2→`keyEqValue` (a `!bool` error-union chain) even when the lookup key is a keyword — yet keywords are INTERNED, so `=` over two keywords IS NaN-box payload bit-identity. destructure (`{:keys [a b c]} m` ×100k = 3 keyword gets/iter) + every keyword config-map lookup pay the chain per entry. (O-049 cut the TLV read inside `eqConsult`; this removes the call chain + error union entirely for the dominant keyword case.) | `arrayMapKeywordSlot(am, kw)`: when `k.tag()==.keyword`, scan `am.entries` comparing `@intFromEnum(entry_key)==@intFromEnum(kw)` inline (no call, no `try`), returning the entry index or null. `get`/`contains` take it on the keyword branch; non-keyword keys keep the general `keyEq` path. Correct because keyword interning makes bit-equality ⟺ `=`, and a keyword can only bit-match a keyword entry (distinct NaN-box tags). The `>8`-entry `.hash_map` path is unchanged (keyword-keyed maps are overwhelmingly small). | **clean old-vs-new ReleaseSafe binary A/B (hyperfine -N, 30 runs, same session): `37_destructure` 51.5→48.1 ms (−6.6%); `27_gc_large_heap` 33.2→31.7 ms (−4.5%); 300k-get microbench 23.7→21.1 ms (−11.0%); map-destructure micro 34.8→32.6 (−6.3%).** Broad win for every keyword `(get map k)` / `(contains? map k)` / `:keys` destructure. | `zig build test -Dwasm` ×2 (diff oracle TreeWalk≡VM, identical Values) + new map.zig unit test (keyword hit/miss + mixed keyword/int/string keys, re-interned keyword identity) + lint | O-048, O-049, O-026, ADR-0165, ADR-0148, D-450, D-520 | |
115 | 115 | | O-050 | `runtime/numeric/promote.zig` (`ratioArith` add/sub branch) + `runtime/numeric/ratio.zig` (`allocFromReducedManagedPair`/`finishReducedPair`) (ADR-0148; ratio_sum) | The BIG-tier ratio add `(an*bd ± bn*ad)/(ad*bd)` reduced via a full gcd in `allocFromManagedPair`. O-046's i64 small tier covers tiny ratios, but the harmonic-sum ACCUMULATOR (`(reduce + …)`) grows past i64 → big-tier add ~45×/call, each paying the big gcd. | Knuth TAOCP 4.5.1 / GMP `mpq_add` gcd-first add: `g = gcd(ad, bd)` FIRST (the added term's denom ≤ 50 → a tiny gcd), reduce by g; coprime denominators (g=1) SKIP the final gcd entirely, else a small `gcd(t, g≤50)`. Result is coprime → `allocFromReducedManagedPair` (factored post-gcd tail of `allocFromManagedPair`, no redundant final gcd; zero-numerator→int-0 guarded). mul/div keep the full reduce. | **`33_ratio_sum` ReleaseSafe 39.6→31.0 ms (hyperfine -N, 15 runs, 1.28×±0.20 over the pre-Knuth baseline, same machine/session A/B).** Complements O-046 (small tier); broad win for all big-tier ratio `+`/`-`. | `zig build test -Dwasm` ×2 (diff oracle) + corpus 3656 + 10 clj-verified edge cases (coprime / g>1 reduction / zero / integer-collapse / negative / large-coprime / harmonic) | O-037, O-046, ADR-0148, D-450 | |
116 | 116 | | O-054 (renumbered 2026-08-05 — the 2026-07-07 D-529 commit duplicated O-051, which the 2026-06-24 keyword-map-get row already held; external O-051 references all mean that row) | ~30 sites across `runtime/` + `lang/primitive/` (grep `PERF:` without an `O-NNN` ref for the live list) | Each site's naive form is stated IN its own marker comment (e.g. "empty + N×conj" vs `fromSlice`; seqFn walk vs index-walk; per-element vs chunk-append) | Self-documenting micro fast-paths: the marker text itself records the naive↔optimized pair, so a dedicated ledger row per site would duplicate the comment without adding information. This umbrella row makes that class OFFICIAL (D-529 audit, 2026-07-07): a `PERF:` marker whose comment states its own naive form and cites no `O-NNN` belongs to this row (O-054) implicitly. New MEASURED optimizations still get their own row. | n/a (micro; individually unmeasured by design) | the dual-backend diff oracle + corpus cover each site's behaviour | D-529 | |
| 117 | +| O-070 | `lang/primitive/string.zig` (`-join` leaf, any seqable) + `lang/clj/clojure/string.clj` `join` (bench/vs_bb string_ops) | 2-arity `join` was `(apply str (interpose sep coll))`: a lazy interpose seq (closure call + lazy cell per element) plus an `apply` arg spill; profiled ~87% of string_ops | `-join` is clj's StringBuilder loop in Zig: vector arm indexes directly, every other seqable walks `seq`/`first`/`next` under a GC-root frame; sep and elements render through `print.writeStrValue` (the `str` renderer), so nil→"" and char/keyword/number render as `str` would. Both arities call it | string_ops cljw 3760→943 ms in-proc (with O-071/O-072; 9.33×→2.27× vs bb) | spot vs clj: vector/list/string/map/empty-set colls, nil sep, nil/char/keyword elements, non-seqable raises IAE | O-012 | |
| 118 | +| O-071 | `runtime/charset.zig` (`upperCaseAlloc`/`lowerCaseAlloc` ASCII fast path) | upper/lower-case walked a `Utf8Iterator` + SpecialCasing/simple-map table lookup per codepoint even for pure-ASCII input | OR-reduce the bytes; all-ASCII → byte-for-byte `std.ascii` fold (every ASCII codepoint's full mapping is its ASCII fold, 1:1). Non-ASCII keeps the table walk (ß→SS unchanged) | part of string_ops 3760→943 ms | `(upper-case "aßc")`→"ASSC", ASCII round trips | D-057 | |
| 119 | +| O-072 | `runtime/regex/match.zig` (`Scanner`) + `runtime/regex/replace.zig` (`splitToVector`) | `split` allocated+freed a fresh VM thread-list pair per match via `findFrom`, then built the result with N persistent `conj`s | One `Scanner` (one VM state) for the whole split; pieces published by `vector.fromSlice` inside a fabrication region | part of string_ops 3760→943 ms | `(split "a,b,,c,," #",")`, `(split "abc" #"")` == clj; regex_parity e2e | O-035, ADR-0150 | |
| 120 | +| O-073 | `lang/primitive/collection.zig` (`__subvec-fast`) + `core.clj` `subvec` | `subvec` ran ~10 interpreted checks + an `->idx` closure alloc per call before the O(1) `__subvec` view | `__subvec-fast` answers the in-bounds immediate-int vector/subvec case natively; nil (never a real subvec result) falls through to the unchanged coercing/throwing path | vector_assoc 1452→1092 ms (with O-074; 3.24×→1.94× vs bb) | subvec nested/1-arity/float index/OOB IOOBE/nil NPE == clj | O-059, D-583 | |
| 121 | +| O-074 | `runtime/collection/vector.zig` (`copyHamt`/`newTail`) | node copies did `.{ .header = … }` (nil-init all 32 slots) then `@memcpy`: every slot written twice on every conj/assoc/pop/pushTail | Write header + slots once; tails copy the live prefix and nil-fill only the dead suffix | part of vector_assoc 1452→1092 ms | zig unit tests + diff oracle | O-040 | |
| 122 | +| O-075 | `lang/primitive/core.zig` (`strFn` stack-buffer path) | multi-arg `str` always built a heap `Allocating` writer (gpa alloc+free) and dispatched `writeStrValue` per arg | when every arg is a string / immediate int / nil and the result fits 256 bytes, concatenate into a stack buffer and allocate the string once; anything else takes the unchanged general path | `(str "item-" i "-x")` x500k 316→144 ms (bb 125) | spot vs clj: nil/int/negative/mixed/float+kw+char fallback/overflow past 256 bytes | O-042 | |
| 123 | +| O-076 | `runtime/keyword.zig` (`stackKey` probe in `internUnlocked`/`findUnlocked`) | every `keyword` intern allocated and freed a `ns/name` lookup key even on a hit | probe the table with a stack-built key (or the name itself when there is no ns); allocate only on a miss or a key over 128 bytes | `(keyword "abc")` x500k 235→104 ms; vector_assoc ~950→~800 ms in-proc (A/B, loaded box) | `=` identity of re-interned long/ns keywords, `find-keyword` hit/miss | O-051 | |
| 124 | +| O-077 | `lang/primitive/chunk_transform.zig` (`__dorun`) + `core.clj` `dorun` 1-arity | `dorun` (and so `doall`) stepped `(next s)` through the interpreter per element | native walk: chunked_cons skips its whole realized chunk via `chunk-rest`, other seqs step with `seqable.next` (realization runs once per element, in order) | `(doall (map identity (range 2000)))` x250 225→135 ms | side-effect counts, lazy/concat mixes, nil/vector/string/map, non-seqable raises IAE | O-032 | |
117 | 125 | | O-090 | `eval/bytecode/serialize.zig` (`readValue` `.list` arm), cold-start axis | Each quoted-list constant decoded from the AOT bootstrap blob took its forward-read scratch buffer from `std.heap.page_allocator` | The buffer comes from the reader's allocator (`ctx.allocator`), as `readCollection` already does; the count header is bounds-checked against the remaining bytes first | `page_allocator` is one `mmap` + `munmap` + first-touch page fault per list, 927 per cold start. `perf stat -r 20` on `cljw -e nil`, ReleaseSafe: task-clock 38.8 → 27.3 ms, kernel instructions 22.2M → 7.9M, page faults 2741 → 1792 (bb: 29.1 ms, 4868 faults); pinned `taskset -c 2`: kernel instructions 29.3M → 12.3M (bb 26.8M), user unchanged 61.6M (bb 16.2M, the residual is D-610) | `test/run_all.sh --smoke` + `perf stat`/`strace -c` A/B | card CLJW-PERF-STARTUP | |
118 | 126 |
|
119 | 127 | ## Identified high-ROI candidates (measured, not yet implemented) |
|
0 commit comments