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#6648 trim tool: Move file removal to the end #6669

Merged
merged 1 commit into from
Feb 21, 2024
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
4 changes: 4 additions & 0 deletions clients/drcachesim/tests/record_filter_unit_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@ process_entries_and_check_result(test_record_filter_t *record_filter,
fprintf(stderr, "Filtering exit failed\n");
return false;
}
if (!record_filter->print_results()) {
fprintf(stderr, "Filtering results failed\n");
return false;
}

std::vector<trace_entry_t> filtered = record_filter->get_output_entries();
// Verbose output for easier debugging.
Expand Down
16 changes: 11 additions & 5 deletions clients/drcachesim/tools/filter/record_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,9 @@ record_filter_t::parallel_shard_exit(void *shard_data)
// chunk_ordinal is 1 after the init-time call for archives; it
// remains 0 for non-archives.
per_shard->chunk_ordinal <= 1 && per_shard->cur_chunk_instrs == 0) {
per_shard->error = remove_output_file(per_shard);
if (!per_shard->error.empty())
res = false;
// Mark for removal. We delay removal in case it involves global
// operations that might race with other workers.
per_shard->now_empty = true;
}
return res;
}
Expand Down Expand Up @@ -617,15 +617,21 @@ record_filter_t::process_memref(const trace_entry_t &memref)
bool
record_filter_t::print_results()
{
bool res = true;
uint64_t input_entry_count = 0;
uint64_t output_entry_count = 0;
for (const auto &shard : shard_map_) {
input_entry_count += shard.second->input_entry_count;
output_entry_count += shard.second->output_entry_count;
if (shard.second->now_empty) {
error_string_ = remove_output_file(shard.second);
if (!error_string_.empty())
res = false;
} else
output_entry_count += shard.second->output_entry_count;
}
std::cerr << "Output " << output_entry_count << " entries from " << input_entry_count
<< " entries.\n";
return true;
return res;
}

} // namespace drmemtrace
Expand Down
1 change: 1 addition & 0 deletions clients/drcachesim/tools/filter/record_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ class record_filter_t : public record_analysis_tool_t {
bool prev_was_output = false;
addr_t filetype = 0;
memref_tid_t tid = 0; // For thread-sharded.
bool now_empty = false;
};

virtual std::string
Expand Down
Loading