Skip to content

Commit

Permalink
i#6844 skip time: Explain rounding down for drmemtrace interpolation (#…
Browse files Browse the repository at this point in the history
…6891)

Adds a comment explaining that rounding down when interpolating for the
drmemtrace skip-to-timestamp feature is the right thing to do, as it
ensures we include a system call that spans the start time and thus will
correctly block/unschedule up front.

Issue: #6844
  • Loading branch information
derekbruening authored Jul 18, 2024
1 parent e859f07 commit 577db95
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions clients/drcachesim/scheduler/scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1321,6 +1321,10 @@ scheduler_tmpl_t<RecordType, ReaderType>::time_tree_lookup(
uint64_t lower_ord = it->second;
double fraction = (time - lower_time) / static_cast<double>(upper_time - lower_time);
double interpolate = lower_ord + fraction * (upper_ord - lower_ord);
// We deliberately round down to ensure we include a system call that spans
// the start time, so we'll get the right starting behavior for a thread that
// should be blocked or unscheduled at this point in time (though the blocked
// time might be too long as it starts before this target time).
ordinal = static_cast<uint64_t>(interpolate);
VPRINT(this, 3,
"time2ordinal: time %" PRIu64 " => times [%" PRIu64 ", %" PRIu64
Expand Down

0 comments on commit 577db95

Please sign in to comment.