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

Configure alternative profiling signal #759

Closed
apangin opened this issue Jun 20, 2023 · 6 comments
Closed

Configure alternative profiling signal #759

apangin opened this issue Jun 20, 2023 · 6 comments

Comments

@apangin
Copy link
Member

apangin commented Jun 20, 2023

Background

Async-profiler heavily relies on POSIX signals. In perf_events and itimer modes, a profiling event triggers delivery of SIGPROF to a currently running thread. In wall mode, a thread being sampled receives SIGVTALRM. Async-profiler assumes the application does not use SIGPROF or SIGVTALRM for other purposes.

Furthermore, since a signal handler is a global property of a process, it is not possible to run two instances of async-profiler on the same process concurrently. For example, this can be helpful for doing some ad-hoc profiling with a custom configuration while continuous profiling is already running.

Proposal

Introduce new signal argument to override the default profiling signal(s). It can be used to configure continuous profiler to avoid conflict with an ad-hoc profiler.

E.g. -agentlib:asyncProfiler=start,event=cpu,signal=36 will force async-profiler use SIGRTMIN+2 instead of SIGPROF for CPU profiling.

To change both cpu and wall signals, we'll use syntax like signal=36/37.

@parttimenerd
Copy link
Contributor

Couldn't async-profiler detect this and choose other signals automatically? The underlying APIs seem to offer the possibility.

@apangin
Copy link
Member Author

apangin commented Jul 12, 2023

What it can detect automatically is whether a signal has a non-default handler. This does not yet tell if a signal is really used, but this could be sufficient in some cases. However, sometimes async-profiler needs to cooperate with an external process, e.g., system-wide eBPF profiling agent. In these cases, the signal should be set explicitly to be in line with what an external agent uses.

@parttimenerd
Copy link
Contributor

parttimenerd commented Jul 12, 2023

What it can detect automatically is whether a signal has a non-default handler.

And maybe warn the user about this fact.

However, sometimes async-profiler needs to cooperate with an external process, e.g., system-wide eBPF profiling agent. In these cases, the signal should be set explicitly to be in line with what an external agent uses.

But maybe we could by default make it choose its signals automatically and have a setting to set them explicitly. Or have a signal=auto option.

@apangin
Copy link
Member Author

apangin commented Jul 14, 2023

I'm not sure how important it is right now, but it's an interesting idea.

@parttimenerd
Copy link
Contributor

When I find time after working on my JEP, I might take a look into this :)

@apangin
Copy link
Member Author

apangin commented Mar 16, 2024

I pushed the fix to automatically find an available signal if the default one is already used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants