Skip to content

Capture Java thread names per-sample for Spark task attribution - #78

Merged
artursarlo merged 6 commits into
masterfrom
async_profiler_thread_rename_2026_06_23
Aug 11, 2026
Merged

Capture Java thread names per-sample for Spark task attribution#78
artursarlo merged 6 commits into
masterfrom
async_profiler_thread_rename_2026_06_23

Conversation

@prashantbytesyntax

Copy link
Copy Markdown

Summary

Enables accurate per-thread attribution in Java flamegraphs for workloads that rename threads at runtime — most importantly Spark executors, which rename their task-pool threads per task (e.g. Executor task launch worker for task 21.0 in stage 492.0).

Two changes:

  • scripts/async_profiler_build_shared.sh — build async-profiler from the v3.0g1_threadpool branch (Granulate/async-profiler#10, "capture thread names for every sample"). Stock v3.0g1 records a thread's name only once, so long-lived Spark executor pool threads keep a stale task/stage label across their lifetime; the threadpool build re-reads the name at each sample.
  • gprofiler/profilers/java.py — add threads to async-profiler's collapsed-output FORMAT_PARAMS so each sample is prefixed with its (now current) thread name.

Why

The Spark-on-k8s per-thread profiling demo (gprofiler-performance-studio#85) relies on thread names to break flamegraphs down by Spark stage/task. With the stock build, attribution silently drifts as executors reuse pool threads for new tasks. This PR makes the thread-name labels trustworthy.

Notes for reviewers

  • This makes per-thread output always on for Java profiling (larger collapsed output / higher frame cardinality). If we'd rather keep it opt-in, the FORMAT_PARAMS hunk can be dropped and threads passed via the existing --java-async-profiler-args=threads flag instead — the build-script change alone is what fixes stale names.
  • The upstream async-profiler branch is an open POC PR on Granulate/async-profiler (not yet merged); we pin an exact GIT_REV so builds are reproducible.
  • Branch history contains a couple of revert/reapply cycles; the net diff is just the two files above.

🤖 Generated with Claude Code

@artursarlo artursarlo left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM. Tested those changes locally on a DEV environment. Working as expected.

@artursarlo
artursarlo merged commit 8c54209 into master Aug 11, 2026
13 of 35 checks passed
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