Skip to content

[dashboard] Add idle query param to CPU profile endpoints#197

Open
matthewdeng wants to merge 1 commit into
masterfrom
cpu-profile-idle-flag
Open

[dashboard] Add idle query param to CPU profile endpoints#197
matthewdeng wants to merge 1 commit into
masterfrom
cpu-profile-idle-flag

Conversation

@matthewdeng
Copy link
Copy Markdown
Owner

Description

Adds an idle query parameter to the /worker/cpu_profile and /task/cpu_profile dashboard endpoints. It's plumbed down to py-spy record --idle, which includes stack traces for idle threads in the output. Previously only --native was wired through.

Example:

/worker/cpu_profile?pid=1334&node_id=...&duration=5&native=0&idle=1

Related issues

None.

Additional information

Files touched

  • src/ray/protobuf/reporter.proto — adds optional bool idle = 5 to CpuProfilingRequest.
  • python/ray/dashboard/modules/reporter/reporter_head.py — both cpu_profile route handlers read idle from the query string and forward it.
  • python/ray/dashboard/modules/reporter/reporter_agent.pyCpuProfiling RPC reads request.idle and passes it through.
  • python/ray/dashboard/modules/reporter/profile_manager.pycpu_profile() accepts idle: bool = False and appends --idle to the py-spy invocation.
  • python/ray/tests/test_dashboard_profiler.pytest_profiler_endpoints now parametrizes idle ∈ {0, 1} on the flamegraph path, mirroring the existing native parametrization. No content assertion is added because the busy-loop test actor has no idle threads to verify; the new combinations exercise the wiring (proto field, py-spy flag) and confirm a valid SVG is still returned.
  • ci/lint/pydoclint-baseline.txt — refreshed (one new entry for the updated ReportHead.cpu_profile docstring; two incidental fixes from cleaner type hints / indentation).

Note for reviewers

Because reporter.proto changed, python/ray/core/generated/reporter_pb2.py will be regenerated by the build. Locally, run /rebuild (or the equivalent bazel proto target) before exercising the new param.

🤖 Generated with Claude Code

Plumbs an `idle` flag through the `/worker/cpu_profile` and
`/task/cpu_profile` endpoints down to `py-spy record`, which exposes
`--idle` to include stack traces for idle threads. Previously only
`--native` was wired through.

- Adds `optional bool idle` to `CpuProfilingRequest` in reporter.proto
- Threads `idle` through reporter_head -> reporter_agent -> CpuProfilingManager
- Appends `--idle` to the py-spy command when set
- Extends test_profiler_endpoints to parametrize `idle` in {0, 1}
- Refreshes pydoclint baseline

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant