kernel: JavaScript member calls stop rescanning whole files per ref
Merged
BO
2mo ago+198+198+012345678901234567890123456789-84-84-01234567890123456789
First batch of the performance pass. Output is unchanged.
The per-verdict-class profiler put pretix's largest resolution cost in JavaScript: 30,792 call refs ended unresolved at about 200 µs each, in bound_receiver_claim. Pretix ships vendored and minified JS, and four steps each did work proportional to the file or the line on every ref:
- Await gate. It scanned every line of the file for
= await x(. The pattern needs a literalawait, so each file now caches itsawaitlines and the gate scans only those. - Receiver-type scan. It walked backwards from the call to the scope start, often line 1. Every receiver pattern needs the receiver literal, so the lines containing it are found once per (file, receiver) with
memmem, and only those are scanned, highest first as before. - Factory initializer. It was re-parsed for every ref through the same binding, and
parens_endwalked the rest of the line after the closing paren. The parse is now memoized per binding, andparens_endreturns at the close. - Line-length guard.
utf16_lencounts from bytes, and the 10,000-unit guard is decided from the byte length when that settles it.
| corpus (wall / resolution) | before | after |
|---|---|---|
| pretix | 10.6 s / 7.7 s | 9.0 s / 6.0 s |
| firefly-iii | 7.9 s / 5.2 s | 6.7 s / 4.7 s |
| linux-fs | 11.7 s / 6.2 s | 10.5 s / 5.7 s |
| warp-drive | 4.6 s / 2.6 s | 4.3 s / 2.2 s |
Peak RSS is within run-to-run noise. The ledger gets §5.43. It also corrects §5.42: tree-sitter's child(i) is linear, not log(i), though the neutral measurement there stands.
Gate: dump-graph byte-identical against the #114 kernel on all 15 corpora. Also: kernel unit tests 35/35 (new: byte-counted utf16_len); clippy -D warnings; ast-grep rules; full suite 303 files, 5,178 tests.