Repository navigation
Make async-profiler per-thread profiling opt-in for Java - #82
Merged
Merged
Conversation
Per-thread profiling (async-profiler's 'threads' output option) was hard-coded on via FORMAT_PARAMS. Make it opt-in and disabled by default, controllable both via CLI and the heartbeat/command-control system. - java.py: drop 'threads' from FORMAT_PARAMS; add per_thread flag to AsyncProfiledProcess and a --java-async-profiler-per-thread CLI arg (store_true, default False) wired through JavaProfiler. - dynamic_profiling_management: map async_profiler config 'per_thread' key (default False) to java_async_profiler_per_thread. - docs/HEARTBEAT_SYSTEM_README.md: document the per_thread field. - tests/utils.py: thread the new arg through make_java_profiler.
artursarlo
added a commit
to pinterest/gprofiler-performance-studio
that referenced
this pull request
Sep 22, 2026
Adds an opt-in, disabled-by-default 'Per-Thread' checkbox to the Async Profiler card in the profiling request interface. When enabled it sets async_profiler.per_thread=true in profiler_configs, which the agent maps to async-profiler's 'threads' output (per pinterest/gprofiler#82). Flows through additional_args unchanged; no backend change required.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Make async-profiler per-thread profiling opt-in for Java
Summary
Per-thread profiling — async-profiler's
threadsoutput option, which splits collapsed stacks by thread name — was hard-coded on in PR #78 viaFORMAT_PARAMS = "ann,sig,threads". That output is needed for Spark task attribution but adds cardinality/overhead that isn't desirable for every workload.This PR makes per-thread profiling opt-in and disabled by default, controllable both from the CLI and from the heartbeat / command-control system. This is the agent-side change; the backend counterpart (surfacing the
per_threadtoggle in the profiling command) will be implemented against this PR.Changes
gprofiler/profilers/java.pyFORMAT_PARAMSback to"ann,sig".per_thread: bool = FalsetoAsyncProfiledProcess; when set it appends,threadsto the async-profiler output args (same pattern asincludemm/includeln).--java-async-profiler-per-thread(store_true, defaultFalse), threaded throughJavaProfiler.gprofiler/dynamic_profiling_management/__init__.py_apply_profiler_configsnow reads an optionalper_threadkey from theasync_profilercommand config (defaultFalse) and setsjava_async_profiler_per_thread.docs/HEARTBEAT_SYSTEM_README.md— documented the newper_threadfield and added an example.tests/utils.py— threadedjava_async_profiler_per_threadthroughmake_java_profiler.How to enable
--java-async-profiler-per-thread.{ "async_profiler": { "enabled": true, "time": "cpu", "per_thread": true } }Behavior change
Default flamegraphs no longer include per-thread splitting. Deployments relying on per-thread output (e.g. Spark task attribution) must opt in via the flag or command config.
Backend follow-up
The backend needs to accept and forward the
per_threadboolean in theasync_profilerprofiler config so it reaches the agent through the heartbeat response (defaultfalsefor backward compatibility).Test plan
,threadsbased on the flag.per_thread: true/falseproduces expected flamegraphs.