#[non_exhaustive]pub enum Transform {
SplitUnit {
unit: UnitId,
numerator: u64,
denominator: NonZeroU64,
dependents: SplitDependents,
overhead: Millis,
},
RemoveEdge {
from: UnitId,
to: UnitId,
},
RemoveUnits {
units: Vec<UnitId>,
},
}Expand description
A hypothetical edit to a build graph.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
SplitUnit
Divide one unit into two, as splitting a crate in a refactor would.
The first part receives numerator / denominator of the unit’s work, rounded to nearest,
and the second receives the remainder, so the two parts sum to exactly the original weight.
overhead is then added to each part, because two crates re-parse shared imports and each
pays a fixed per-crate cost.
A part’s metadata_at is scaled by that part’s share of the denominator and then clamped
so that it never exceeds the part’s own total. The clamp is reachable through rounding
alone: a unit of 999ms that emits metadata at 999ms, divided at one half, gives parts of
500ms and 499ms while both metadata times round to 500ms, and the second is clamped to
499ms. overhead is added to the total but not to metadata_at, so the metadata boundary
of a part is the earliest the split could plausibly reach.
Both parts inherit every incoming edge with its original kind, along with kind and
requires_full_closure. Where the outgoing edges go is decided by dependents:
SplitDependents::Pessimistic gives every dependent an edge from both parts, and
SplitDependents::Optimistic gives each dependent one edge, from the part that finishes
first.
A build script cannot be split: one invocation of one program is not divisible, and
numerator may not exceed denominator.
Fields
denominator: NonZeroU64The denominator of that fraction.
dependents: SplitDependentsWhich part each dependent is assumed to need.
RemoveEdge
Remove one dependency edge, as deleting a use of one crate from another would.
Only the edge goes; both units stay, even if one of them is left with nothing depending on
it. Removing a unit is Transform::RemoveUnits.
RemoveUnits
Remove units, as dropping a dependency or turning off a feature would.
Removing a unit also removes everything that existed only to serve it. Precisely: let a root be a unit that had no dependents in the original graph, which is what the build was asked to produce. After the named units are removed, every surviving unit that can no longer reach a surviving root by following dependents is removed as well. Reachability is reflexive, so a surviving root reaches itself and always survives.
Naming a unit twice is not an error, and removing every unit gives a valid empty graph.