Commit 2e164b2
WebGPURenderer: Remove per-draw WeakMap.set allocation in pipeline dedup.
`WebGPUPipelineUtils.setPipeline` tracked the active pipeline per pass
encoder via a WeakMap. Pass encoders are created fresh every frame, so
each pipeline change fired `_activePipelines.set( pass, pipeline )` —
allocating a new entry hundreds of times per second. Sampled heap
profile attributed ~64 KB / 10 s to this one line on webgpu_backdrop_water.
We already track the active pipeline in `currentSets.pipeline` (render)
and can do the same on the compute group's data entry. Inline the
dedup at both call sites, delete the WeakMap, delete the method.
Bonus: use an Array for `currentSets.attributes` instead of `{}` and
reset with `.length = 0` — avoids the `for…in / delete` loop in
`_resetCurrentSets` that caused hidden-class transitions.
Measured on webgpu_backdrop_water (Inspector stripped, 10 s, 1 KB
sampling): `update @ Animation.js:70` subtree 402 KB → 341 KB (−15%).
`animate` child subtree 135 KB → 61 KB (−55%).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 04f1d1a commit 2e164b2
2 files changed
Lines changed: 18 additions & 37 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| |||
908 | 908 | | |
909 | 909 | | |
910 | 910 | | |
911 | | - | |
| 911 | + | |
912 | 912 | | |
913 | 913 | | |
914 | 914 | | |
| |||
952 | 952 | | |
953 | 953 | | |
954 | 954 | | |
955 | | - | |
| 955 | + | |
956 | 956 | | |
957 | 957 | | |
958 | 958 | | |
| |||
1603 | 1603 | | |
1604 | 1604 | | |
1605 | 1605 | | |
1606 | | - | |
| 1606 | + | |
| 1607 | + | |
1607 | 1608 | | |
1608 | 1609 | | |
1609 | 1610 | | |
1610 | 1611 | | |
1611 | 1612 | | |
1612 | | - | |
| 1613 | + | |
| 1614 | + | |
| 1615 | + | |
| 1616 | + | |
| 1617 | + | |
| 1618 | + | |
1613 | 1619 | | |
1614 | 1620 | | |
1615 | 1621 | | |
| |||
1736 | 1742 | | |
1737 | 1743 | | |
1738 | 1744 | | |
1739 | | - | |
1740 | | - | |
| 1745 | + | |
| 1746 | + | |
| 1747 | + | |
| 1748 | + | |
| 1749 | + | |
| 1750 | + | |
1741 | 1751 | | |
1742 | 1752 | | |
1743 | 1753 | | |
| |||
2365 | 2375 | | |
2366 | 2376 | | |
2367 | 2377 | | |
2368 | | - | |
| 2378 | + | |
2369 | 2379 | | |
2370 | 2380 | | |
2371 | 2381 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | 41 | | |
71 | 42 | | |
72 | 43 | | |
| |||
0 commit comments