Commit f40827f
committed
perf(dataflow): solve each function once instead of three times
The L4 serial tail (compute_summaries + assemble_sdg, ~48% of the
dataflow layer) was re-deriving the same per-function solution three
times over. Instrumenting solve_function on the flask fixture: 1,158
calls for 386 functions, and solve_function is 95% of the tail's wall
time.
Two independent causes, both fixed:
- Singleton SCCs iterated twice. compute_summaries ran
`while changed`, so a non-recursive function computed its summary,
set changed=True, then recomputed an identical summary purely to
observe convergence. The condensation DAG is walked bottom-up, so a
one-member SCC with no self-edge has all callee summaries final
already and cannot change on a second pass. Genuinely recursive SCCs
(several members, or one calling itself) still iterate to fixpoint.
- assemble_sdg re-solved from scratch. compute_summaries discarded its
own intermediates (`new, _, _ = solve_function(...)`) and the
assembler then called solve_function again per signature to recover
the facts and DDG. compute_summaries now optionally hands back the
converged (facts, ddg) and the assembler consumes them. Sound because
a converged pass is by definition one in which no member changed, so
those by-products already reflect the final summaries. The recompute
path remains the default for callers whose summaries did not come
from an immediately preceding run over the same infos.
Measured: solve calls 3.0x -> 1.0x per function (386 for 386, zero in
the assembler). Interleaved A/B/A/B on erpnext L4 with --ray, load
recorded per run: FIXED 231s/257s vs BASELINE 263s/282s, means 244s vs
272s = 10.5% faster; the worst FIXED run still beats the best BASELINE
run, so the result survives this machine's load swings.
Output is unchanged: flask L4 matches the pre-change baseline exactly
on callables (386), cfg (4,372), cdg (2,443), ddg (24,138), summary
(3,449), param_in (1,608), param_out (1,201) and the full ddg
provenance histogram.
Full suite: 291 passed, 6 skipped.
Closes #155.1 parent cda4d24 commit f40827f
3 files changed
Lines changed: 51 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
428 | 428 | | |
429 | 429 | | |
430 | 430 | | |
431 | | - | |
432 | | - | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
433 | 438 | | |
434 | 439 | | |
435 | 440 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
386 | 386 | | |
387 | 387 | | |
388 | 388 | | |
| 389 | + | |
| 390 | + | |
389 | 391 | | |
390 | | - | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
391 | 401 | | |
392 | 402 | | |
393 | 403 | | |
| |||
396 | 406 | | |
397 | 407 | | |
398 | 408 | | |
399 | | - | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
400 | 415 | | |
401 | 416 | | |
402 | 417 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
199 | 199 | | |
200 | 200 | | |
201 | 201 | | |
| 202 | + | |
| 203 | + | |
202 | 204 | | |
203 | 205 | | |
204 | | - | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
205 | 221 | | |
| 222 | + | |
206 | 223 | | |
207 | 224 | | |
208 | 225 | | |
209 | | - | |
210 | | - | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
211 | 230 | | |
212 | 231 | | |
213 | | - | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
214 | 235 | | |
215 | 236 | | |
216 | 237 | | |
| 238 | + | |
| 239 | + | |
217 | 240 | | |
0 commit comments