-
Notifications
You must be signed in to change notification settings - Fork 579
i#3995 irregular window tracing: last window bug fix #7448
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
base: master
Are you sure you want to change the base?
Changes from all commits
e28b7a3
8f039e6
f6dc8a1
dcec71e
a8f7b69
32afadd
c4a6928
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,7 @@ | |
#include <stddef.h> | ||
#include <atomic> | ||
#include <cstdint> | ||
#include <inttypes.h> | ||
|
||
// These libraries are safe to use during initialization only. | ||
// See api/docs/deployment.dox sec_static_DR. | ||
|
@@ -156,6 +157,8 @@ get_current_no_trace_for_instrs_value() | |
return 0; | ||
} | ||
|
||
// This function returns true if, at the current no-trace window, there exists an | ||
// instruction count threshold to enable tracing. | ||
static bool | ||
has_instr_count_threshold_to_enable_tracing() | ||
{ | ||
|
@@ -470,6 +473,13 @@ parse_instr_intervals_file(std::string path_to_file) | |
if (!std::getline(ss, elem, ',')) | ||
FATAL("Fatal error: instruction duration not found.\n"); | ||
uint64 duration = std::stoull(elem); | ||
if (duration == 0) { | ||
NOTIFY(0, | ||
"Instruction interval starting at %" PRIu64 " has duration of 0. " | ||
"Removing interval.\n", | ||
start); | ||
continue; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The main changes from the last review are:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please update the PR description. |
||
} | ||
// Ignore the remaining comma-separated elements, if any. | ||
|
||
instr_intervals.emplace_back(start, duration); | ||
|
@@ -488,13 +498,18 @@ parse_instr_intervals_file(std::string path_to_file) | |
// 2) Overlapping intervals must be merged. | ||
std::vector<instr_interval_t> instr_intervals_merged; | ||
instr_intervals_merged.emplace_back(instr_intervals[0]); | ||
for (instr_interval_t &interval : instr_intervals) { | ||
for (size_t i = 1; i < instr_intervals.size(); ++i) { | ||
instr_interval_t &interval = instr_intervals[i]; | ||
uint64 end = interval.start + interval.duration; | ||
instr_interval_t &last_interval = instr_intervals_merged.back(); | ||
uint64 last_end = last_interval.start + last_interval.duration; | ||
if (interval.start <= last_end) { | ||
edeiana marked this conversation as resolved.
Show resolved
Hide resolved
|
||
uint64 max_end = last_end > end ? last_end : end; | ||
last_interval.duration = max_end - last_interval.start; | ||
NOTIFY(0, | ||
"Instruction interval starting at %" PRIu64 " has been merged with " | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe make this log more concise by denoting intervals as |
||
"instruction interval starting at %" PRIu64 " .\n", | ||
last_interval.start, interval.start); | ||
} else { | ||
instr_intervals_merged.emplace_back(interval); | ||
} | ||
|
@@ -550,9 +565,9 @@ compute_irregular_trace_windows(std::vector<instr_interval_t> &instr_intervals) | |
// must have a duration long enough to cover the end of the program. | ||
irregular_window_ptr = | ||
(irregular_window_t *)dr_global_alloc(sizeof(irregular_window_t)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about other uses of DELAY_FOREVER_THRESHOLD? I see instr_count_threshold() still returns that when There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My understanding is that However, what actually blocks the creation of the unwanted window is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I didn't understand this statement. In your example does it return Even if other logic prevents its use, it seems weird to leave There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The previous behavior (which caused the bug), would have
Is the suggestion to change the name of this constant because misleading? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Indeed the name is confusing. Renaming would help. |
||
// DELAY_FOREVER_THRESHOLD might be too small for long traces, but it doesn't matter | ||
// because we trace_for_instrs = 0, so no window is created anyway. | ||
irregular_window_ptr->no_trace_for_instrs = DELAY_FOREVER_THRESHOLD; | ||
// We assume that a no_trace_for_instrs of UINT64_MAX is a long enough period that we | ||
// stop tracing for the remaining execution of the traced program. | ||
irregular_window_ptr->no_trace_for_instrs = UINT64_MAX; | ||
irregular_window_ptr->trace_for_instrs = 0; | ||
drvector_set_entry(&irregular_windows_list, num_intervals, irregular_window_ptr); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before submitting, maybe we should test this on a large app to make sure everything is WAI.