Commit 5983a42
committed
⚡️ perf: cache pools in FSM state machine
Adds an in-memory pool cache to StateMachine, mirroring the existing
accounts cache. GetPool checks the cache before hitting Pebble; SetPool
populates the cache after a successful store write (cache-after-write
avoids leaking uncommitted state if the store op fails).
Returned and cached pools are deep-cloned via clonePool() to prevent
pointer aliasing on the Points slice — a caller mutating its returned
Pool.Points cannot affect the cached entry, and SetPool callers cannot
leak external mutation into the cache.
The pools map is wired through New(), Copy(), and ResetCaches() so
it is invalidated on per-tx rollback (state.go:338) and per-block
reset, alongside the accounts cache.
Targets the per-block 90s GetPool cost observed in staging localnet-1
profiling (177K calls × 0.504ms).1 parent 22fae6e commit 5983a42
3 files changed
Lines changed: 35 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
253 | 253 | | |
254 | 254 | | |
255 | 255 | | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
256 | 269 | | |
257 | 270 | | |
258 | 271 | | |
| |||
261 | 274 | | |
262 | 275 | | |
263 | 276 | | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
264 | 281 | | |
265 | 282 | | |
266 | 283 | | |
| |||
273 | 290 | | |
274 | 291 | | |
275 | 292 | | |
| 293 | + | |
| 294 | + | |
276 | 295 | | |
277 | 296 | | |
278 | 297 | | |
| |||
334 | 353 | | |
335 | 354 | | |
336 | 355 | | |
337 | | - | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
338 | 363 | | |
339 | 364 | | |
340 | 365 | | |
| |||
345 | 370 | | |
346 | 371 | | |
347 | 372 | | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
348 | 376 | | |
349 | 377 | | |
350 | 378 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
| |||
66 | 67 | | |
67 | 68 | | |
68 | 69 | | |
| 70 | + | |
69 | 71 | | |
70 | 72 | | |
71 | 73 | | |
| |||
604 | 606 | | |
605 | 607 | | |
606 | 608 | | |
| 609 | + | |
607 | 610 | | |
608 | 611 | | |
609 | 612 | | |
| |||
714 | 717 | | |
715 | 718 | | |
716 | 719 | | |
| 720 | + | |
717 | 721 | | |
718 | 722 | | |
719 | 723 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
76 | 77 | | |
77 | 78 | | |
78 | 79 | | |
| |||
415 | 416 | | |
416 | 417 | | |
417 | 418 | | |
| 419 | + | |
418 | 420 | | |
419 | 421 | | |
420 | 422 | | |
| |||
0 commit comments