Skip to main content

Module predict

Module predict 

Source
Expand description

What psync’s schedule would make of a measured run: a what-if prediction.

The input is a Report and a trace of one sequential run: every measured call, with the source line it was made from and what it cost (in any unit: milliseconds, polls). The trace already says which path the run took, because a call on a branch that was not taken has no sample. The prediction replays psync’s schedule for that path:

  • in a region, every level costs its slowest chain, and a chain costs the sum of its nodes;
  • in a prefetched loop, the prefixes of all items run first, at most bound at once, each starting when a slot frees; the rest of each body then runs in order;
  • every other call costs what it cost.

The levels’ slowest chains are the critical path. The model is psync’s own: a level waits for all of its chains (see Levels), so it predicts what psync does, not what a dataflow schedule could do.

A sample belongs to the statement whose lines contain it. A loop’s items are told apart by where its prefix starts again, and its runs (one per iteration of an enclosing loop) by the samples between them.

Structs§

LoopTiming
The prediction for one prefetched loop.
PathTiming
The runs that took one path through a function, and their predictions.
Prediction
The prediction for one run of a function.
RegionTiming
The prediction for one region.
Sample
One measured call: the line it was made from, and its cost.

Functions§

makespan
When the last of jobs ends, if they start in order, each as soon as one of slots frees.
predict
Predict the time of the run that produced trace, under the schedule report describes.
predict_loop 🔒
A loop’s samples are split into runs of the loop (a sample outside it ends a run: an outer loop’s next iteration), and each run into items: an item starts with a prefix sample that comes after the rest of the body, or after a sample of the same or a later prefix statement.
predict_paths
Predict many runs and group them by path, most frequent path first (ties: the order the paths first appear). Each path gets its own critical path; the runs’ share of each path is the condition under which that critical path is the one that matters.
predict_region 🔒
within 🔒
Whether line falls in the lines first..=last of a statement (never for unknown lines).