Commit 8a4840a
perf(validator): pool trackers and lazily allocate the consumed-tag Set
`beginTrackFrame` allocated a `new Tracker()` and the Tracker allocated a
`new Set<Tag>()` — two objects per frame — on *every* reference recompute
and every cache group, every revalidation. The overwhelming majority of
frames consume zero or one tag.
- The Tracker now holds the first consumed tag in a field and allocates the
`Set` only when a second, distinct tag arrives. 0/1-tag frames never touch
a Set (and still dedupe / combine correctly).
- Trackers are pooled on a LIFO freelist. Frames are strictly nested and a
tracker is dead the instant `combine()` runs in `endTrackFrame`, so it can
be reset and reused by the next `beginTrackFrame`.
Net: the common tracking frame now allocates ~nothing. Microbench: a
frame that opens, consumes one tag, and closes drops from two object
allocations to ~0 b/iter (measured 0.10 b for the 0-tag case).
Full browser suite green: 9340 tests, 9323 pass, 17 skip, 0 fail.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 9b7a4f5 commit 8a4840a
1 file changed
Lines changed: 55 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
12 | 20 | | |
13 | 21 | | |
14 | | - | |
15 | | - | |
| 22 | + | |
| 23 | + | |
16 | 24 | | |
17 | 25 | | |
18 | 26 | | |
19 | 27 | | |
20 | | - | |
21 | | - | |
22 | 28 | | |
23 | 29 | | |
24 | 30 | | |
25 | 31 | | |
26 | | - | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
27 | 48 | | |
28 | 49 | | |
29 | 50 | | |
30 | | - | |
| 51 | + | |
31 | 52 | | |
32 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
33 | 56 | | |
34 | | - | |
35 | | - | |
36 | 57 | | |
37 | | - | |
| 58 | + | |
38 | 59 | | |
39 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
40 | 80 | | |
41 | 81 | | |
42 | 82 | | |
| |||
59 | 99 | | |
60 | 100 | | |
61 | 101 | | |
62 | | - | |
| 102 | + | |
63 | 103 | | |
64 | 104 | | |
65 | 105 | | |
| |||
79 | 119 | | |
80 | 120 | | |
81 | 121 | | |
82 | | - | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
83 | 126 | | |
84 | 127 | | |
85 | 128 | | |
| |||
0 commit comments