Skip to content

Commit

Permalink
i#5636: Fix elided duplicate timestamps (#5643)
Browse files Browse the repository at this point in the history
PR #5633 added code to skip the duplicate timestamps at the top of
each chunk: but its logic assumed there would never be two legitimate
timestamps with identical values.  That does happen, in particular in
our online-drcachesim tests on Windows.  This resulted in the
invariant_checker not seeing some timestamp entries, causing its
exception for non-fetched instrs across thread switches to not apply
and resulting in invariant error reports.

We fix this by skipping the first timestamp in each chunk by
instruction count instead.  We'll want the insruction and chunk
counts for #5538 and I was about to add those fields in any case.

Fixes #5636
  • Loading branch information
derekbruening authored Sep 9, 2022
1 parent 2de559c commit b73a792
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
14 changes: 10 additions & 4 deletions clients/drcachesim/reader/reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ reader_t::operator++()
cur_ref_.instr.addr = cur_pc_;
next_pc_ = cur_pc_ + cur_ref_.instr.size;
prev_instr_addr_ = input_entry_->addr;
if (cur_ref_.instr.type != TRACE_TYPE_INSTR_NO_FETCH)
++cur_instr_count_;
}
break;
case TRACE_TYPE_INSTR_BUNDLE:
Expand Down Expand Up @@ -225,17 +227,21 @@ reader_t::operator++()
// cached timestamp and cpu as do linear portion of seek, and then emit
// cached top-level headers plus the last timestamp+cpu at the target
// point.
if (cur_ref_.marker.marker_type == TRACE_MARKER_TYPE_TIMESTAMP &&
cur_ref_.marker.marker_value == last_timestamp_) {
if (chunk_instr_count_ > 0 &&
cur_ref_.marker.marker_type == TRACE_MARKER_TYPE_TIMESTAMP &&
cur_instr_count_ / chunk_instr_count_ !=
last_timestamp_instr_count_ / chunk_instr_count_) {
skip_next_cpu_ = true;
} else if (cur_ref_.marker.marker_type == TRACE_MARKER_TYPE_CPU_ID &&
skip_next_cpu_) {
skip_next_cpu_ = false;
} else {
if (cur_ref_.marker.marker_type == TRACE_MARKER_TYPE_TIMESTAMP)
last_timestamp_ = cur_ref_.marker.marker_value;
have_memref = true;
}
if (cur_ref_.marker.marker_type == TRACE_MARKER_TYPE_TIMESTAMP)
last_timestamp_instr_count_ = cur_instr_count_;
else if (cur_ref_.marker.marker_type == TRACE_MARKER_TYPE_CHUNK_INSTR_COUNT)
chunk_instr_count_ = cur_ref_.marker.marker_value;
break;
default:
ERRMSG("Unknown trace entry type %d\n", input_entry_->type);
Expand Down
4 changes: 3 additions & 1 deletion clients/drcachesim/reader/reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ class reader_t : public std::iterator<std::input_iterator_tag, memref_t> {
addr_t prev_instr_addr_ = 0;
int bundle_idx_ = 0;
std::unordered_map<memref_tid_t, memref_pid_t> tid2pid_;
uint64_t last_timestamp_ = 0;
uint64_t cur_instr_count_ = 0;
uint64_t chunk_instr_count_ = 0; // Unchanging once set to non-zero.
uint64_t last_timestamp_instr_count_ = 0;
bool skip_next_cpu_ = false;
};

Expand Down

0 comments on commit b73a792

Please sign in to comment.