Commit fefe840
committed
perf(basin): cache baseline vacuum across candidates (skill/uma basin)
Profiling a basin (localStorage.torena_perf) showed wall=28s was ~all genuine,
well-parallelized worker compute (14.5x on a 16-pool; main-thread plan-build was
0%). The dominant redundancy: every candidate re-simulates the *baseline* vacuum
(runner without the tracked skill), which is identical across all candidates at a
given sample count — the planner already caches this, the basin pools did not.
Pool workers now memoize the baseline result per run (keyed by seed + sample
count + baseline skill order; reset on init), so the baseline is simulated once
per stage per worker instead of once per skill. Each cached result is read-only
in the reduction, and the key captures the exact (rare) per-candidate sort
variations — so every simulation is byte-identical to before, just not recomputed.
Roughly halves basin worker compute (baseline is ~half the runCompare calls).
typecheck + lint + 221 tests + build + worker guard green.1 parent e7e2884 commit fefe840
3 files changed
Lines changed: 46 additions & 9 deletions
File tree
- src
- modules/simulation/simulators
- workers/pool
- skill-basin
- uma-basin
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
216 | 233 | | |
217 | | - | |
| 234 | + | |
| 235 | + | |
218 | 236 | | |
219 | 237 | | |
220 | 238 | | |
221 | 239 | | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
226 | 250 | | |
227 | 251 | | |
228 | 252 | | |
| |||
268 | 292 | | |
269 | 293 | | |
270 | 294 | | |
271 | | - | |
| 295 | + | |
| 296 | + | |
272 | 297 | | |
273 | 298 | | |
274 | 299 | | |
275 | 300 | | |
276 | 301 | | |
277 | | - | |
| 302 | + | |
278 | 303 | | |
279 | 304 | | |
280 | 305 | | |
| |||
Lines changed: 7 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
18 | 23 | | |
19 | 24 | | |
20 | 25 | | |
21 | 26 | | |
22 | 27 | | |
23 | 28 | | |
24 | | - | |
| 29 | + | |
25 | 30 | | |
26 | 31 | | |
27 | 32 | | |
| |||
31 | 36 | | |
32 | 37 | | |
33 | 38 | | |
| 39 | + | |
34 | 40 | | |
35 | 41 | | |
36 | 42 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
18 | 23 | | |
19 | 24 | | |
20 | 25 | | |
21 | 26 | | |
22 | 27 | | |
23 | 28 | | |
24 | | - | |
| 29 | + | |
25 | 30 | | |
26 | 31 | | |
27 | 32 | | |
| |||
31 | 36 | | |
32 | 37 | | |
33 | 38 | | |
| 39 | + | |
34 | 40 | | |
35 | 41 | | |
36 | 42 | | |
| |||
0 commit comments