Skip to content

Commit

Permalink
i#2039 trace trim, part 5: Drop early data
Browse files Browse the repository at this point in the history
Part 4 added a minimum timestamp, but it only works for data that is
not actually emitted until we are fully attached.  For data emitted
before that point, we'll use a too-early timestamp.  We solve that
here by dropping such data.

Tested on a large app where these changes solve gaps at the start of
the trace due to an early timestamp in one thread.

Issue: #2039
  • Loading branch information
derekbruening committed Nov 30, 2022
1 parent 1f40176 commit 156faad
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions clients/drcachesim/tracer/output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,6 @@ process_and_output_buffer(void *drcontext, bool skip_size_cap)
// the first buffer.
if (data->has_thread_header && op_offline.get_value())
header_size += data->init_header_size;
data->has_thread_header = false;

if (align_attach_detach_endpoints()) {
// This is the attach counterpart to instru_t::set_frozen_timestamp(): we place
Expand All @@ -927,12 +926,20 @@ process_and_output_buffer(void *drcontext, bool skip_size_cap)
// tracing. (Switching back to timestamps at buffer output is actually
// worse as we then have the identical frozen timestamp for all the flushes
// during detach, plus they are all on the same cpu too.)
uint64 min_timestamp = attached_timestamp.load(std::memory_order_acquire);
if (min_timestamp == 0) {
// This data is too early: we drop it.
BUF_PTR(data->seg_base) = data->buf_base + header_size;
return;
}
size_t stamp_offs =
header_size > buf_hdr_slots_size ? header_size - buf_hdr_slots_size : 0;
uint64 min_timestamp = attached_timestamp.load(std::memory_order_acquire);
instru->refresh_unit_header_timestamp(data->buf_base + stamp_offs, min_timestamp);
}

// Clear after we know we're not dropping for align_attach_detach_endpoints.
data->has_thread_header = false;

buf_ptr = BUF_PTR(data->seg_base);
// We may get called with nothing to write: e.g., on a syscall for
// -L0I_filter and -L0D_filter.
Expand Down

0 comments on commit 156faad

Please sign in to comment.