Skip to content

Conversation

r1viollet
Copy link
Collaborator

What does this PR do?

To prevent clearing mmap data when it is not useful, we consider timestamps of comm and fork events.

Motivation

We encountered an issue where we gather mmap data just prior to a comm event. The comm event clears the data.
Then we are unable to compute the offset from an elf file.

Additional Notes

NA

How to test the change?

I added a unit test.
I will check with user if this fixes the issue he encountered or if we need to go further.

To prevent clearing mmap data when it is not useful, we consider timestamps of comm and fork events
@pr-commenter
Copy link

pr-commenter bot commented Jan 23, 2024

Benchmark results for collatz

Parameters

Baseline Candidate
config baseline candidate
profiler-version ddprof 0.15.3+a078c6cd.27241841 ddprof 0.15.3+a521115d.27247464

Summary

Found 0 performance improvements and 0 performance regressions! Performance is the same for 1 metrics, 0 unstable metrics.

See unchanged results
scenario Δ mean execution_time
scenario:ddprof -S bench-collatz --preset cpu_only collatz_runner.sh same

@pr-commenter
Copy link

pr-commenter bot commented Jan 23, 2024

Benchmark results for BadBoggleSolver_run

Parameters

Baseline Candidate
config baseline candidate
profiler-version ddprof 0.15.3+a078c6cd.27241841 ddprof 0.15.3+a521115d.27247464

Summary

Found 0 performance improvements and 0 performance regressions! Performance is the same for 1 metrics, 0 unstable metrics.

See unchanged results
scenario Δ mean execution_time
scenario:ddprof -S bench-bad-boggle-solver BadBoggleSolver_run work 1000 same

Ensure caches are not cleared when PID maps are not cleared
src/unwind.cc Outdated
if (!(us->dso_hdr.pid_free(pid, timestamp))) {
LG_DBG("(PID Free)%d -> avoid free of mappings (%ld)", pid,
timestamp.time_since_epoch().count());
} else {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the mappings are good. Does it really mean that the underlying dwfl modules are OK ?
Today we do not really tie the lifetime of the mappings to the lifetimes of the unwinding caches.
So I am not sure about this change. I think it requires more careful thinking.
@nsavoire fyi

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree

// 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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to only call pid_fork when pid mappings have actually been freed.

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));
Copy link
Collaborator

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 of worker_pid_free (with and without timestamp) or having PerfClock::time_point::max() as default value for timestamp in worker_pid_free would be more natural.

src/unwind.cc Outdated
if (!(us->dso_hdr.pid_free(pid, timestamp))) {
LG_DBG("(PID Free)%d -> avoid free of mappings (%ld)", pid,
timestamp.time_since_epoch().count());
} else {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree

@r1viollet r1viollet marked this pull request as draft January 26, 2024 13:14
Communicate the result of the unwind free to caller
@r1viollet r1viollet changed the title Consider timestamps in comm and fork events [PROF-9088] Consider timestamps in comm and fork events Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants