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

Add raw2trace statistic for instr count #6347

Merged
merged 4 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 10 additions & 0 deletions clients/drcachesim/tracer/raw2trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1214,6 +1214,7 @@ raw2trace_t::do_conversion()
earliest_trace_timestamp_, thread_data_[i]->earliest_trace_timestamp);
latest_trace_timestamp_ = std::max(latest_trace_timestamp_,
thread_data_[i]->latest_trace_timestamp);
final_trace_instr_count_ += thread_data_[i]->final_trace_instr_count;
}
} else {
// The files can be converted concurrently.
Expand All @@ -1238,6 +1239,7 @@ raw2trace_t::do_conversion()
std::min(earliest_trace_timestamp_, tdata->earliest_trace_timestamp);
latest_trace_timestamp_ =
std::max(latest_trace_timestamp_, tdata->latest_trace_timestamp);
final_trace_instr_count_ += tdata->final_trace_instr_count;
}
}
error = aggregate_and_write_schedule_files();
Expand All @@ -1254,6 +1256,8 @@ raw2trace_t::do_conversion()
count_rseq_side_exit_);
VPRINT(1, "Trace duration %.3fs.\n",
(latest_trace_timestamp_ - earliest_trace_timestamp_) / 1000000.0);
VPRINT(1, "Final trace instr count: " UINT64_FORMAT_STRING ".\n",
final_trace_instr_count_);
VPRINT(1, "Successfully converted %zu thread files\n", thread_data_.size());
return "";
}
Expand Down Expand Up @@ -3055,6 +3059,8 @@ raw2trace_t::write(raw2trace_thread_data_t *tdata, const trace_entry_t *start,
if (type_is_instr(static_cast<trace_type_t>(it->type)) &&
// Do not count PC-only i-filtered instrs.
it->size > 0) {
accumulate_to_statistic(tdata,
RAW2TRACE_STAT_FINAL_TRACE_INSTRUCTION_COUNT, 1);
++tdata->cur_chunk_instr_count;
++instr_ordinal;
if (TESTANY(OFFLINE_FILE_TYPE_ENCODINGS, tdata->file_type) &&
Expand Down Expand Up @@ -3502,6 +3508,9 @@ raw2trace_t::accumulate_to_statistic(raw2trace_thread_data_t *tdata,
case RAW2TRACE_STAT_LATEST_TRACE_TIMESTAMP:
tdata->latest_trace_timestamp = std::max(tdata->latest_trace_timestamp, value);
break;
case RAW2TRACE_STAT_FINAL_TRACE_INSTRUCTION_COUNT:
tdata->final_trace_instr_count += value;
break;
default: DR_ASSERT(false);
}
}
Expand All @@ -3517,6 +3526,7 @@ raw2trace_t::get_statistic(raw2trace_statistic_t stat)
case RAW2TRACE_STAT_RSEQ_SIDE_EXIT: return count_rseq_side_exit_;
case RAW2TRACE_STAT_EARLIEST_TRACE_TIMESTAMP: return earliest_trace_timestamp_;
case RAW2TRACE_STAT_LATEST_TRACE_TIMESTAMP: return latest_trace_timestamp_;
case RAW2TRACE_STAT_FINAL_TRACE_INSTRUCTION_COUNT: return final_trace_instr_count_;
default: DR_ASSERT(false); return 0;
}
}
Expand Down
5 changes: 4 additions & 1 deletion clients/drcachesim/tracer/raw2trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ typedef enum {
RAW2TRACE_STAT_RSEQ_SIDE_EXIT,
RAW2TRACE_STAT_FALSE_SYSCALL,
RAW2TRACE_STAT_EARLIEST_TRACE_TIMESTAMP,
RAW2TRACE_STAT_LATEST_TRACE_TIMESTAMP
RAW2TRACE_STAT_LATEST_TRACE_TIMESTAMP,
RAW2TRACE_STAT_FINAL_TRACE_INSTRUCTION_COUNT
} raw2trace_statistic_t;

struct module_t {
Expand Down Expand Up @@ -1065,6 +1066,7 @@ class raw2trace_t {
uint64 count_rseq_side_exit = 0;
uint64 earliest_trace_timestamp = (std::numeric_limits<uint64>::max)();
uint64 latest_trace_timestamp = 0;
uint64 final_trace_instr_count = 0;

uint64 cur_chunk_instr_count = 0;
uint64 cur_chunk_ref_count = 0;
Expand Down Expand Up @@ -1255,6 +1257,7 @@ class raw2trace_t {
uint64 count_rseq_side_exit_ = 0;
uint64 earliest_trace_timestamp_ = (std::numeric_limits<uint64>::max)();
uint64 latest_trace_timestamp_ = 0;
uint64 final_trace_instr_count_ = 0;
abhinav92003 marked this conversation as resolved.
Show resolved Hide resolved

std::unique_ptr<module_mapper_t> module_mapper_;

Expand Down
Loading