-
Notifications
You must be signed in to change notification settings - Fork 5
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
Make allocation profiling work after exec #342
Conversation
Benchmark results for collatzParameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 1 metrics, 0 unstable metrics. See unchanged results
|
Benchmark results for BadBoggleSolver_runParameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 1 metrics, 0 unstable metrics. See unchanged results
|
b7b6411
to
a95dfb7
Compare
a95dfb7
to
6a91d73
Compare
check "./ddprof bash -c \"./test/simple_malloc ${opts}\"" 1 | ||
|
||
# Test disabling follow execs | ||
check "env DD_PROFILING_NATIVE_ALLOCATION_PROFILING_FOLLOW_EXECS=0 DD_PROFILING_NATIVE_STARTUP_WAIT_MS=200 ./ddprof bash -c \"./test/simple_malloc ${opts}\"" 0 0 "inuse-space" |
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.
Interesting to test the removal of the feature. For overhead, there might be a use case where users do not want to follow some execs. Good thinking.
src/ddprof_cli.cc
Outdated
@@ -297,10 +297,14 @@ int DDProfCLI::parse(int argc, const char *argv[]) { | |||
app.add_flag("--help_extended", help_extended, "Show extended options") | |||
->group("")); | |||
extended_options.push_back( | |||
app.add_option("--socket", socket, | |||
"Profiler's IPC socket, as a file descriptor") | |||
app.add_option("--socket", socket_path, "Profiler socket path") |
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.
Minor: we could give a more detailed explanation of why we establish this socket.
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.
Do you mean adding details to the help text or adding comments to explain why we need a socket ?
FYI I added an overview of the communication process between profiler/library here.
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.
As a user I would be confused with what I can do with this.
The overview is great.
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.
I guess these are more developer options. We do not use them apart from testing use cases. Would something like:
Override the automatically created socket with a specific path
Be better ?
ddprof now keeps a unix socket open, unix socket path can be overridden with --socket input option. Worker accepts connections on this socket in a separate thread and sends ring buffer information upon request. When a new process is exec'd, library looks up DD_PROFILING_NATIVE_LIB_SOCKET env variable to get socket path and if it exists, connects to it otherwise it spawns a ddprof process, then uses a pipe to synchronize with ddprof start and get socket path, and then connects to it. By default ddprof creates an abstract socket, that does not exist on the filesystem: \0/tmp/ddprof-<pid>.sock. This behaviour can be disabled by setting env variable DD_PROFILING_NATIVE_ALLOCATION_PROFILING_FOLLOW_EXECS to 0/off/no.
6a91d73
to
d57d94b
Compare
@@ -109,6 +111,45 @@ DDRes spawn_workers(PersistentWorkerState *persistent_worker_state, | |||
return {}; | |||
} | |||
|
|||
ReplyMessage create_reply_message(const DDProfContext &ctx) { |
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.
minor: it feels slightly weird to have this function defined here.
src/perf_mainloop.cc
Outdated
|
||
if (ctx.watchers[alloc_watcher_idx].aggregation_mode == | ||
EventAggregationMode::kLiveSum) { | ||
reply.allocation_flags |= (1 << ReplyMessage::kLiveCallgraph); |
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 seems someone forgot to rename the options all the way down 😅
int pfd_len = 0; | ||
pollfd_setup(&ctx.worker_ctx.pevent_hdr, poll_fds, &pfd_len); | ||
|
||
DDRES_CHECK_FWD(signalfd_setup(&poll_fds[pfd_len])); | ||
int const signal_pos = pfd_len++; | ||
|
||
WorkerServer const server = |
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.
Somehow I had not thought about making this a separate thread. I thought we would make it live within the mainloop.
I think it is better this way.
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.
LGTM
A very impressive capability.
I am eager to start playing with this.
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.
LGTM
What does this PR do?
This PR add the ability to profile allocations even after a process has exec'd into a new binary image.
How do this work ?
ddprof now keeps a unix socket open, unix socket path can be overridden with
--socket
input option.Worker accepts connections on this socket in a separate thread and sends ring buffer information upon request.
When a new process is exec'd, library looks up
DD_PROFILING_NATIVE_LIB_SOCKET
env variable to get socket path and if it exists, connects to it otherwise it spawns a ddprof process, then uses a pipe to synchronize with ddprof start and get socket path, and then connects to it.By default ddprof creates an abstract socket, that does not exist on the filesystem:
\0/tmp/ddprof-<pid>.sock
.Exec following can be disabled by setting env variable
DD_PROFILING_NATIVE_ALLOCATION_PROFILING_FOLLOW_EXECS
to 0/off/no.