Commit 69c7480
Upsert instead of remove + insert, improving worst case from timeout to 6min
Summary:
When a target's hash or CI labels change, we previously called
graph.remove_target() followed by store_target_to_graph(), tearing down all
dependency edges and rebuilding them from scratch. This is O(deg) work per
update even when the dependency list hasn't changed — which is the common case.
This replaces that pattern with upsert_target_in_graph which:
1. Overwrites metadata in-place (store_minimized_target is already idempotent)
2. Diffs regular dep edges: computes old vs new sets, applies only the delta
3. Diffs CI hint edges: same approach for CI hint targets
4. Overwrites CI patterns (store_ci_* methods are already idempotent)
For hash-only changes (common case): the edge diff is empty, so zero edge
work is done. For dep changes: only the delta edges are touched. For new
targets: old edges are empty, so the diff naturally produces only adds.
Timeout cases now finish in time:
Case 1:
Before: >120 min
https://www.internalfb.com/sandcastle/workflow/3837066882533555449
After: 6min 16s
https://www.internalfb.com/sandcastle/workflow/495395959024731311/insights
Case 2:
Before: >120 min
https://www.internalfb.com/sandcastle/workflow/3837066882533549678
After: 5min 34s
https://www.internalfb.com/sandcastle/workflow/198158383618412384
Case 3:
Before > 120min
https://www.internalfb.com/sandcastle/workflow/3837066882533546745
After: 6min 31s
https://www.internalfb.com/sandcastle/workflow/2053641430094751390
BTD succeeds, verse failure is unrelated
creds to RiskRunner0 for initial idea
Reviewed By: RiskRunner0
Differential Revision: D93272049
fbshipit-source-id: ef814aa6ae416d3d10afa6f1069b9e4e5233bb291 parent 08d441d commit 69c7480
1 file changed
+7
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
65 | 67 | | |
66 | 68 | | |
67 | 69 | | |
| |||
473 | 475 | | |
474 | 476 | | |
475 | 477 | | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
476 | 482 | | |
477 | 483 | | |
478 | 484 | | |
| |||
0 commit comments