Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i#2039 trace trim, part 5: Drop early data #5768

Merged
merged 2 commits into from
Dec 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions clients/drcachesim/tracer/instru_offline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,8 @@ offline_instru_t::refresh_unit_header_timestamp(byte *buf_ptr, uint64 min_timest
offline_entry_t *stamp = reinterpret_cast<offline_entry_t *>(buf_ptr);
DR_ASSERT(stamp->timestamp.type == OFFLINE_TYPE_TIMESTAMP);
if (stamp->timestamp.usec < min_timestamp) {
log_(2, "%s: replacing " UINT64_FORMAT_STRING " with " UINT64_FORMAT_STRING "\n",
__FUNCTION__, stamp->timestamp.usec, min_timestamp);
stamp->timestamp.usec = min_timestamp;
return true;
}
Expand Down
12 changes: 10 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,21 @@ 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.
NOTIFY(1, "Dropping too-early data for T%zd\n", dr_get_thread_id(drcontext));
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
4 changes: 3 additions & 1 deletion clients/drcachesim/tracer/tracer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,9 @@ event_post_attach()
DR_ASSERT(attached_midway);
if (!align_attach_detach_endpoints())
return;
attached_timestamp.store(instru_t::get_timestamp(), std::memory_order_release);
uint64 timestamp = instru_t::get_timestamp();
attached_timestamp.store(timestamp, std::memory_order_release);
NOTIFY(1, "Fully-attached timestamp is " UINT64_FORMAT_STRING "\n", timestamp);
if (op_trace_after_instrs.get_value() != 0) {
NOTIFY(1, "Switching to counting mode after attach\n");
tracing_mode.store(BBDUP_MODE_COUNT, std::memory_order_release);
Expand Down