Commit 5a0d226
committed
perf(@angular/build): avoid full JSON parsing when updating sourcemap ignore list
Previously, the sourcemap ignore-list plugin parsed the entire generated sourcemap buffer into a JavaScript object via JSON.parse and re-serialized it via JSON.stringify to inject x_google_ignoreList.
In typical applications, sourcemap files range from 2 MB to 10 MB+ each. The sources array constitutes less than 1% of the total file size, with the vast majority of the payload comprised of sourcesContent and VLQ-encoded mappings. Parsing and re-stringifying this large structure generates significant V8 heap churn (5x to 6x transient allocations per sourcemap) and incurs 20 ms to 60 ms of single-threaded blocking time per chunk.
To eliminate redundant parsing and serialization overhead:
- Scan the buffer to extract and parse only the sources JSON array.
- Determine the node modules ignore list indices using the extracted sources array.
- Splice the serialized x_google_ignoreList property directly into the output buffer adjacent to the root object delimiter without parsing or allocating intermediate strings for sourcesContent or mappings.
- Gracefully fall back to full JSON parsing and serialization if non-standard JSON formatting is encountered.
In benchmarks on 2.4 MB to 10.4 MB sourcemap files, ignore-list processing dropped from 20.3 ms to 0.60 ms (33.9x faster) and 60.2 ms to 2.27 ms (26.5x faster), respectively, while reducing heap churn by more than 99%.1 parent d11a663 commit 5a0d226
1 file changed
Lines changed: 120 additions & 0 deletions
Lines changed: 120 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
24 | 34 | | |
25 | 35 | | |
26 | 36 | | |
| |||
29 | 39 | | |
30 | 40 | | |
31 | 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 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
32 | 119 | | |
33 | 120 | | |
34 | 121 | | |
| |||
68 | 155 | | |
69 | 156 | | |
70 | 157 | | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
71 | 187 | | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
72 | 192 | | |
73 | 193 | | |
74 | 194 | | |
| |||
0 commit comments