pub fn dispatch_sort_key(
candidate: &PrefetchCandidate,
) -> (u32, u8, Reverse<Option<u64>>)Expand description
Sort key for dispatch order, lowest first (#617).
Lexicographic, deliberately, rather than a weighted score: a weighted sum needs coefficients, and nothing can calibrate them until #618 makes “arrived before it was demanded” measurable. Every element here is an ordering, not a magnitude.
- Urgency bucket. Prefetch races the build, so a high-value artifact needed at minute eight loses to a medium-value one needed at second five. Candidates with no demand index sort last.
- Confidence. Within one wave, prefer the source most likely to be right.
- Value, descending. Expensive rebuilds first, so the limited slots buy the most avoided work. Unknown cost sorts after known cost rather than being scored as zero.
Callers must apply this as a STABLE sort: equal keys keep source order, which is the planner’s confidence-merge order.