Commit e760262
Ralph Küpper
perf(regex): hold the site table's programs weakly, and stop the added counters moving the dump
Two corrections from the I6 cc arm, both found by reading the instrument back
rather than by argument.
**1. The site table must never be the reason a program stays alive.** Measured
on one 3300-char reply: settled footprint 478/474 MB -> 500/527 MB and idle CPU
2.37 -> 2.68 s against main. 1,024 entries at ~19 KB per compiled program is
that order, and the campaign's directive is both metrics together — a CPU win
bought with resident memory does not land. The entry now holds
`Weak<Regex>` / `Weak<fancy_regex::Regex>` / `Weak<RepeatMatcherRegex>`;
strong references stay where they belong, in the `(pattern, flags)` program
caches and in every live header that installed them with `Arc::into_raw`. An
entry whose programs have expired reports "not built yet" and the next
construction re-picks them up from the content cache — the same path the site's
first construction takes, so the lane self-heals.
The upgrade is ALL-OR-NOTHING. #9801 fixed an incoherent triple — a standard
program memoized beside a missing fancy fallback — which does not error, it
silently never matches; three independent `Arc` lifetimes reintroduce exactly
that shape unless one dead reference invalidates the whole entry. Pinned by a
test that drops ONLY the fancy program and asserts the entry reports unbuilt,
which the natural per-field upgrade fails.
**2. An added counter moved the instrument's own sampling.** `regex_with`
counts every call as an event and dumps every `TICK_EVERY` events after a
second has passed, so a second probe on an already-instrumented path doubles
that path's event rate and moves the snapshot a SIGKILLed process leaves
behind. On the I6 pair that showed up as `new / t` 206 k/s vs 173 k/s between
two arms whose per-call ratios agree to 0.13 %, i.e. the two files describe
different windows of the same workload. `regex_counters` accumulates without
ticking the dump clock, and the three counters that ride along on already
instrumented paths (barrier gate outcome, side-table inserts, site-verify
bytes) now use it.1 parent 61b4c21 commit e760262
4 files changed
Lines changed: 206 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
187 | 187 | | |
188 | 188 | | |
189 | 189 | | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
190 | 217 | | |
191 | 218 | | |
192 | 219 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1473 | 1473 | | |
1474 | 1474 | | |
1475 | 1475 | | |
1476 | | - | |
| 1476 | + | |
1477 | 1477 | | |
1478 | 1478 | | |
1479 | 1479 | | |
| |||
1544 | 1544 | | |
1545 | 1545 | | |
1546 | 1546 | | |
1547 | | - | |
| 1547 | + | |
1548 | 1548 | | |
1549 | 1549 | | |
1550 | 1550 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
151 | | - | |
| 151 | + | |
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
50 | 50 | | |
51 | 51 | | |
52 | 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 | + | |
53 | 102 | | |
54 | 103 | | |
55 | 104 | | |
| |||
79 | 128 | | |
80 | 129 | | |
81 | 130 | | |
82 | | - | |
| 131 | + | |
83 | 132 | | |
84 | 133 | | |
85 | 134 | | |
| |||
136 | 185 | | |
137 | 186 | | |
138 | 187 | | |
139 | | - | |
| 188 | + | |
140 | 189 | | |
141 | 190 | | |
142 | 191 | | |
| |||
169 | 218 | | |
170 | 219 | | |
171 | 220 | | |
172 | | - | |
173 | | - | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
174 | 234 | | |
175 | 235 | | |
176 | 236 | | |
| |||
193 | 253 | | |
194 | 254 | | |
195 | 255 | | |
196 | | - | |
| 256 | + | |
197 | 257 | | |
198 | 258 | | |
199 | 259 | | |
| |||
212 | 272 | | |
213 | 273 | | |
214 | 274 | | |
215 | | - | |
216 | | - | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
217 | 283 | | |
218 | 284 | | |
219 | 285 | | |
| |||
247 | 313 | | |
248 | 314 | | |
249 | 315 | | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
0 commit comments