-
Notifications
You must be signed in to change notification settings - Fork 9
[PROF-9088] Consider timestamps in comm and fork events #366
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
Draft
r1viollet
wants to merge
3
commits into
main
Choose a base branch
from
r1viollet/fix_comm
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,7 +47,8 @@ const DDPROF_STATS s_cycled_stats[] = { | |
const long k_clock_ticks_per_sec = sysconf(_SC_CLK_TCK); | ||
|
||
/// Remove all structures related to | ||
DDRes worker_pid_free(DDProfContext &ctx, pid_t el); | ||
DDRes worker_pid_free(DDProfContext &ctx, pid_t el, | ||
PerfClock::time_point timestamp); | ||
|
||
DDRes clear_unvisited_pids(DDProfContext &ctx); | ||
|
||
|
@@ -231,7 +232,7 @@ DDRes ddprof_unwind_sample(DDProfContext &ctx, perf_event_sample *sample, | |
if (us->_dwfl_wrapper && us->_dwfl_wrapper->_inconsistent) { | ||
// Loaded modules were inconsistent, assume we should flush everything. | ||
LG_WRN("(Inconsistent DWFL/DSOs)%d - Free associated objects", us->pid); | ||
DDRES_CHECK_FWD(worker_pid_free(ctx, us->pid)); | ||
DDRES_CHECK_FWD(worker_pid_free(ctx, us->pid, PerfClock::now())); | ||
} | ||
return res; | ||
} | ||
|
@@ -303,19 +304,21 @@ DDRes aggregate_live_allocations(DDProfContext &ctx) { | |
return {}; | ||
} | ||
|
||
DDRes worker_pid_free(DDProfContext &ctx, pid_t el) { | ||
DDRes worker_pid_free(DDProfContext &ctx, pid_t el, | ||
PerfClock::time_point timestamp) { | ||
DDRES_CHECK_FWD(aggregate_live_allocations_for_pid(ctx, el)); | ||
UnwindState *us = ctx.worker_ctx.us; | ||
unwind_pid_free(us, el); | ||
unwind_pid_free(us, el, timestamp); | ||
ctx.worker_ctx.live_allocation.clear_pid(el); | ||
return {}; | ||
} | ||
|
||
DDRes clear_unvisited_pids(DDProfContext &ctx) { | ||
UnwindState *us = ctx.worker_ctx.us; | ||
const std::vector<pid_t> pids_remove = us->dwfl_hdr.get_unvisited(); | ||
const PerfClock::time_point now = PerfClock::now(); | ||
for (pid_t const el : pids_remove) { | ||
DDRES_CHECK_FWD(worker_pid_free(ctx, el)); | ||
DDRES_CHECK_FWD(worker_pid_free(ctx, el, now)); | ||
} | ||
us->dwfl_hdr.reset_unvisited(); | ||
return {}; | ||
|
@@ -584,21 +587,21 @@ void ddprof_pr_lost(DDProfContext &ctx, const perf_event_lost *lost, | |
} | ||
|
||
DDRes ddprof_pr_comm(DDProfContext &ctx, const perf_event_comm *comm, | ||
int watcher_pos) { | ||
int watcher_pos, PerfClock::time_point timestamp) { | ||
// Change in process name (assuming exec) : clear all associated dso | ||
if (comm->header.misc & PERF_RECORD_MISC_COMM_EXEC) { | ||
LG_DBG("<%d>(COMM)%d -> %s", watcher_pos, comm->pid, comm->comm); | ||
DDRES_CHECK_FWD(worker_pid_free(ctx, comm->pid)); | ||
DDRES_CHECK_FWD(worker_pid_free(ctx, comm->pid, timestamp)); | ||
} | ||
return {}; | ||
} | ||
|
||
DDRes ddprof_pr_fork(DDProfContext &ctx, const perf_event_fork *frk, | ||
int watcher_pos) { | ||
int watcher_pos, PerfClock::time_point timestamp) { | ||
LG_DBG("<%d>(FORK)%d -> %d/%d", watcher_pos, frk->ppid, frk->pid, frk->tid); | ||
if (frk->ppid != frk->pid) { | ||
// Clear everything and populate at next error or with coming samples | ||
DDRES_CHECK_FWD(worker_pid_free(ctx, frk->pid)); | ||
DDRES_CHECK_FWD(worker_pid_free(ctx, frk->pid, timestamp)); | ||
ctx.worker_ctx.us->dso_hdr.pid_fork(frk->pid, frk->ppid); | ||
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. It would be better to only call |
||
} | ||
return {}; | ||
|
@@ -745,8 +748,11 @@ DDRes ddprof_worker_process_event(const perf_event_header *hdr, int watcher_pos, | |
break; | ||
case PERF_RECORD_COMM: | ||
if (wpid->pid) { | ||
DDRES_CHECK_FWD(ddprof_pr_comm( | ||
ctx, reinterpret_cast<const perf_event_comm *>(hdr), watcher_pos)); | ||
auto timestamp = perf_clock_time_point_from_timestamp( | ||
hdr_time(hdr, watcher->sample_type)); | ||
DDRES_CHECK_FWD( | ||
ddprof_pr_comm(ctx, reinterpret_cast<const perf_event_comm *>(hdr), | ||
watcher_pos, timestamp)); | ||
} | ||
break; | ||
case PERF_RECORD_EXIT: | ||
|
@@ -757,8 +763,11 @@ DDRes ddprof_worker_process_event(const perf_event_header *hdr, int watcher_pos, | |
break; | ||
case PERF_RECORD_FORK: | ||
if (wpid->pid) { | ||
DDRES_CHECK_FWD(ddprof_pr_fork( | ||
ctx, reinterpret_cast<const perf_event_fork *>(hdr), watcher_pos)); | ||
auto timestamp = perf_clock_time_point_from_timestamp( | ||
hdr_time(hdr, watcher->sample_type)); | ||
DDRES_CHECK_FWD( | ||
ddprof_pr_fork(ctx, reinterpret_cast<const perf_event_fork *>(hdr), | ||
watcher_pos, timestamp)); | ||
} | ||
|
||
break; | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
It weird to have to call
PerfClock::now()
here, perhaps having two versions ofworker_pid_free
(with and without timestamp) or havingPerfClock::time_point::max()
as default value fortimestamp
inworker_pid_free
would be more natural.