Commit f453083
perf(walker-gate): cache reachable set per flush invocation
The property-based walker gate (commit ce94475) replaced a tiny
class-name allowlist (Class::MOP/Moose/Moo) with a per-object flag
storedInPackageGlobal. This semantically correct change widened the
gate to fire on far more blessed objects -- DBIx::Class stores many
blessed instances (Schema, ResultSource, Storage::DBI) into package-
global hashes and uses weaken() liberally for back-refs, so most of
its objects now satisfy the gate at MortalList.flush().
Each gate fire ran ReachabilityWalker.isReachableFromRoots(target),
an O(globals) BFS. With N targets per flush, total cost was
O(N x globals) -- quadratic. Surfaced as a 100% CPU spin in DBI-
generated SQL dispatch code under HARNESS_OPTIONS=j4 parallel runs
(t/100populate.t, t/101populate_rs.t, t/100extra_source.t etc. never
completed; standalone runs stayed fast because their flush queues
are smaller).
Fix: compute the reachable set once per flush via the existing
ReachabilityWalker.walk() and reuse for O(1) membership lookups.
Cleared in the finally block so subsequent flushes recompute against
fresh global state.
Verified:
- DBIx::Class parallel-harness batch that previously hung now passes
in 47s (16 tests, 327 subtests).
- DBIx::Class t/52leaks.t still passes (the leak-detection test the
walker gate exists to protect).
- Moo 841/841, Moose 5/5, Template Toolkit 2660/2660 unchanged.
- make unit tests pass.
Generated with [Devin](https://cli.devin.ai/docs)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>1 parent a86a1ca commit f453083
2 files changed
Lines changed: 21 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| |||
Lines changed: 19 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
562 | 562 | | |
563 | 563 | | |
564 | 564 | | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
565 | 582 | | |
566 | 583 | | |
567 | 584 | | |
| |||
591 | 608 | | |
592 | 609 | | |
593 | 610 | | |
594 | | - | |
| 611 | + | |
595 | 612 | | |
596 | 613 | | |
597 | 614 | | |
| |||
616 | 633 | | |
617 | 634 | | |
618 | 635 | | |
| 636 | + | |
619 | 637 | | |
620 | 638 | | |
621 | 639 | | |
| |||
0 commit comments