Skip to content

Commit

Permalink
i#6727: Ignore wait records in record_filter (#6730)
Browse files Browse the repository at this point in the history
Updates record_filter to ignore TRACE_MARKER_TYPE_CORE_WAIT records.
These are artificial timing records: we do not want to output them, nor
consider them real input records.

Adds a unit test.

Fixes #6727
  • Loading branch information
derekbruening authored Mar 26, 2024
1 parent 781f15e commit 8b3f924
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
44 changes: 43 additions & 1 deletion clients/drcachesim/tests/record_filter_unit_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1052,6 +1052,48 @@ test_null_filter()
return true;
}

static bool
test_wait_filter()
{
// Test that wait records (artificial timing during replay) are not preserved.
constexpr addr_t TID = 5;
constexpr addr_t PC_A = 0x1234;
constexpr addr_t ENCODING_A = 0x4321;
std::vector<test_case_t> entries = {
{ { TRACE_TYPE_HEADER, 0, { 0x1 } }, true, { true } },
{ { TRACE_TYPE_MARKER, TRACE_MARKER_TYPE_VERSION, { 0x2 } }, true, { true } },
{ { TRACE_TYPE_MARKER,
TRACE_MARKER_TYPE_FILETYPE,
{ OFFLINE_FILE_TYPE_ENCODINGS } },
true,
{ true } },
{ { TRACE_TYPE_THREAD, 0, { TID } }, true, { true } },
{ { TRACE_TYPE_PID, 0, { 0x5 } }, true, { true } },
{ { TRACE_TYPE_MARKER, TRACE_MARKER_TYPE_CACHE_LINE_SIZE, { 0x6 } },
true,
{ true } },
{ { TRACE_TYPE_MARKER, TRACE_MARKER_TYPE_TIMESTAMP, { 100 } }, true, { true } },
{ { TRACE_TYPE_MARKER, TRACE_MARKER_TYPE_CPU_ID, { 0 } }, true, { true } },
{ { TRACE_TYPE_ENCODING, 2, { ENCODING_A } }, true, { true } },
{ { TRACE_TYPE_INSTR, 2, { PC_A } }, true, { true } },
// Test wait and idle records.
{ { TRACE_TYPE_MARKER, TRACE_MARKER_TYPE_CORE_WAIT, { 0 } }, true, { false } },
{ { TRACE_TYPE_MARKER, TRACE_MARKER_TYPE_CORE_WAIT, { 0 } }, true, { false } },
{ { TRACE_TYPE_MARKER, TRACE_MARKER_TYPE_CORE_IDLE, { 0 } }, true, { true } },
{ { TRACE_TYPE_MARKER, TRACE_MARKER_TYPE_CORE_WAIT, { 0 } }, true, { false } },
{ { TRACE_TYPE_MARKER, TRACE_MARKER_TYPE_CORE_IDLE, { 0 } }, true, { true } },
{ { TRACE_TYPE_THREAD_EXIT, 0, { TID } }, true, { true } },
{ { TRACE_TYPE_FOOTER, 0, { 0xa2 } }, true, { true } },
};
std::vector<std::unique_ptr<record_filter_func_t>> filters;
auto record_filter = std::unique_ptr<test_record_filter_t>(
new test_record_filter_t(std::move(filters), 0, /*write_archive=*/true));
if (!process_entries_and_check_result(record_filter.get(), entries, 0))
return false;
fprintf(stderr, "test_wait_filter passed\n");
return true;
}

int
test_main(int argc, const char *argv[])
{
Expand All @@ -1063,7 +1105,7 @@ test_main(int argc, const char *argv[])
droption_parser_t::usage_short(DROPTION_SCOPE_ALL).c_str());
}
if (!test_cache_and_type_filter() || !test_chunk_update() || !test_trim_filter() ||
!test_null_filter())
!test_null_filter() || !test_wait_filter())
return 1;
fprintf(stderr, "All done!\n");
return 0;
Expand Down
6 changes: 6 additions & 0 deletions clients/drcachesim/tools/filter/record_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,12 @@ record_filter_t::process_markers(per_shard_t *per_shard, trace_entry_t &entry,
"supported";
}
break;
case TRACE_MARKER_TYPE_CORE_WAIT:
// These are artificial timing records: do not output them, nor consider
// them real input records.
output = false;
--per_shard->input_entry_count;
break;
}
}
return "";
Expand Down

0 comments on commit 8b3f924

Please sign in to comment.