Commit 4809a3c
authored
Move more functions off of
## Objective
- Part of #20115
- Reduce `ScheduleGraph` implementation surface and extract reusable
parts.
## Solution
- Upgraded and exposed `Dag<N>` as a fully-fledged directed acyclic
graph type.
- The validity of the cached topological order is now tracked by a
`dirty` flag. All modifications to the graph (via `DerefMut` or
`Dag::graph_mut`) cause the DAG to be marked as dirty.
- Added `Dag::toposort`: if the DAG is dirty, computes topological
order, caches it, and marks the DAG as clean. If already clean, returns
the cached topological order. We now also reuse the previous toposort
`Vec` allocation.
- Added `Dag::get_toposort`: can be used to access the topological order
with `&self`, with the stipulation that it returns an `Option`, and
`None` if the DAG is dirty.
- Replaced `check_graph` with `Dag::analyze`, and made it publicly
accessible.
- Added `Dag::remove_redundant_edges`, which uses the output of
`Dag::analyze`.
- Renamed `CheckGraphResults` to `DagAnalysis`.
- Added `DagAnalysis::check_for_redundant_edges`, replacing
`ScheduleGraph::optionally_check_hierarchy_conflicts`.
- Added `DagAnalysis::check_for_cross_dependencies`, replacing
`ScheduleGraph::check_for_cross_dependencies`. It now takes two full
`DagAnalysis` for comparison.
- Added `DagAnalysis::check_for_cross_intersection`, replacing
`ScheduleGraph::check_order_but_intersect`.
- Added `DagGroups` to encapsulate the `HashMap<SystemSetKey,
Vec<SystemKey>>` with additional capabilities:
- `DagGroups::flatten` and `DagGroups::flatten_undirected` handle the
graph reduction operations previously performed by functions on
`ScheduleGraph`.
- Added `ConflictingSystems` to encapsulate `Vec<(SystemKey, SystemKey,
ComponentId)>` with additional capabilities and type safety.
See the included migration guide for breaking changes.
# Testing
- Ran examples
- Added new tests for `Dag`, `DagAnalysis`, and `DagGroups`
functionality.
# Future work
- Consider replacing `HashSet<SystemKey>` with a `FixedBitSet`-like type
for better performance.ScheduleGraph (#21817)1 parent d87d491 commit 4809a3c
File tree
10 files changed
+1347
-669
lines changed- crates/bevy_ecs/src/schedule
- graph
- release-content/migration-guides
10 files changed
+1347
-669
lines changedLines changed: 12 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
| 75 | + | |
76 | 76 | | |
77 | | - | |
78 | | - | |
79 | | - | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | | - | |
| 127 | + | |
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
| |||
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
149 | | - | |
| 149 | + | |
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
| |||
179 | 179 | | |
180 | 180 | | |
181 | 181 | | |
182 | | - | |
| 182 | + | |
183 | 183 | | |
184 | 184 | | |
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
188 | | - | |
| 188 | + | |
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
| |||
215 | 215 | | |
216 | 216 | | |
217 | 217 | | |
218 | | - | |
| 218 | + | |
219 | 219 | | |
220 | 220 | | |
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
224 | 224 | | |
225 | | - | |
| 225 | + | |
226 | 226 | | |
227 | 227 | | |
228 | 228 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | | - | |
10 | | - | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
11 | 15 | | |
12 | 16 | | |
13 | 17 | | |
| |||
26 | 30 | | |
27 | 31 | | |
28 | 32 | | |
29 | | - | |
30 | | - | |
| 33 | + | |
| 34 | + | |
31 | 35 | | |
32 | | - | |
33 | | - | |
| 36 | + | |
| 37 | + | |
34 | 38 | | |
35 | | - | |
36 | | - | |
| 39 | + | |
| 40 | + | |
37 | 41 | | |
38 | 42 | | |
39 | 43 | | |
| |||
56 | 60 | | |
57 | 61 | | |
58 | 62 | | |
59 | | - | |
| 63 | + | |
60 | 64 | | |
61 | 65 | | |
62 | 66 | | |
| |||
66 | 70 | | |
67 | 71 | | |
68 | 72 | | |
69 | | - | |
70 | | - | |
| 73 | + | |
| 74 | + | |
71 | 75 | | |
72 | 76 | | |
73 | 77 | | |
| |||
101 | 105 | | |
102 | 106 | | |
103 | 107 | | |
104 | | - | |
105 | | - | |
| 108 | + | |
| 109 | + | |
106 | 110 | | |
107 | | - | |
| 111 | + | |
108 | 112 | | |
109 | 113 | | |
110 | | - | |
| 114 | + | |
111 | 115 | | |
112 | 116 | | |
113 | 117 | | |
| |||
195 | 199 | | |
196 | 200 | | |
197 | 201 | | |
198 | | - | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
199 | 207 | | |
200 | 208 | | |
201 | 209 | | |
| |||
227 | 235 | | |
228 | 236 | | |
229 | 237 | | |
230 | | - | |
| 238 | + | |
231 | 239 | | |
232 | 240 | | |
233 | 241 | | |
| |||
236 | 244 | | |
237 | 245 | | |
238 | 246 | | |
239 | | - | |
| 247 | + | |
240 | 248 | | |
241 | 249 | | |
242 | 250 | | |
| |||
261 | 269 | | |
262 | 270 | | |
263 | 271 | | |
264 | | - | |
| 272 | + | |
265 | 273 | | |
266 | 274 | | |
267 | | - | |
| 275 | + | |
268 | 276 | | |
269 | 277 | | |
270 | 278 | | |
| |||
0 commit comments