Chrometrace profiling support#49
Open
lee1258561 wants to merge 13 commits intopinterest/main-2.52.1from
Open
Conversation
This change adds support for py-spy's native chrometrace format output, enabling timeline-based CPU profiling visualization in Perfetto UI. Backend changes: - Add 'chrometrace' to supported formats in profile_manager.py - Add 'rate' parameter for configurable sampling rate (default 100 Hz) - Update reporter_agent.py to pass rate parameter - Update reporter_head.py to set Content-Type: application/json and CORS headers for chrometrace format to allow Perfetto UI fetching Frontend changes: - Add CpuProfilingButton component with dialog for configuring: - Format: Flamegraph (SVG), Chrome Trace (Timeline), Speedscope - Duration: 1-60 seconds - Sampling Rate: 1-1000 Hz - Native: Include C/C++ stack frames (Linux only) - Add "Open in Perfetto" button for chrometrace format - Replace CpuProfilingLink with CpuProfilingButton in all pages - Replace TaskCpuProfilingLink with TaskCpuProfilingButton Protobuf changes: - Add 'rate' field to CpuProfilingRequest message Tests: - Add test_profiler_chrometrace_format test Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The "Open in Viewer" button was failing because Speedscope's URL constructor requires an absolute URL with protocol and host, but we were passing a relative path. Now we use window.location.origin to build the full absolute URL dynamically, which works regardless of how the dashboard is accessed (localhost, IP, or proxy). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds "Open in Perfetto" button for chrometrace format that opens ui.perfetto.dev with trace data using postMessage protocol. Includes a confirmation dialog warning users about sending data to third-party site. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Integrates the open-source chrome://tracing viewer (Catapult) directly into the Ray dashboard for fully local chrometrace visualization without sending data to external services. Changes: - Add trace-viewer/ static assets (built from Catapult project) - Add URL loading support via hash parameter (#traceURL=...) - Add "Open in Trace Viewer" button for chrometrace format - Rename existing button to "Open in Speedscope" for clarity Benefits: - Security: No profile data sent to third-party sites - Offline: Works in air-gapped environments - UX: Same experience as chrome://tracing Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Use original about_tracing.html which contains all required <template> elements (like #profiling-view-template) that the JS code needs - Rename about_tracing.js to tracing.js to match original HTML reference - Add URL loading script with hash-based traceURL parameter support Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The setActiveTrace function is asynchronous - it returns immediately but loads the model via a promise internally. Instead of hiding the overlay right after calling setActiveTrace, poll for when the timelineView.model is populated with processes before removing the loading overlay. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use inline style.display='none' instead of classList.add('hidden')
to override the inline display:flex that has higher CSS specificity.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove speedscope from format dropdown, keep flamegraph and chrometrace - Add new py-spy options exposed in UI: GIL Only, Include Idle, Non-blocking - Always enable --threads flag for thread ID visibility - Update protobuf, backend API, and profile manager to support new options Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add getBasePath() helper to extract base path from current URL - Update openInSpeedscope, openInTraceViewer, and openInPerfetto to use base path for correct URL generation behind proxy - Change CpuProfilerButton and ProfilerButton wrappers from <div> to React.Fragment to fix inline layout issues Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
lishunyao97
approved these changes
Mar 13, 2026
lishunyao97
left a comment
There was a problem hiding this comment.
Very cool work! thanks for adding this
Tests cover button rendering, dialog interactions, py-spy options (native, GIL, idle, nonblocking), chrometrace viewer buttons (Speedscope, Trace Viewer, Perfetto), and default format selection. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
This PR adds Chrome Trace format support for CPU profiling in the Ray Dashboard, enabling temporal/timeline-based profiling
alongside the existing flamegraph format. Users can now choose between three visualization methods when profiling actors, tasks,
jobs, or nodes.
Key Changes
Chrome Trace format support: Added
chrometraceformat option to py-spy profiler, generating timeline-based profiles thatshow when functions execute over time
Three visualization options:
Embedded Catapult Trace Viewer: Bundled the Chromium Catapult trace-viewer for fully local visualization without sending data
to external services
Visualization Method Comparison
Key Insight: Chrome Trace Viewer is the only option that provides a unified stack view across multiple threads, making it
essential for debugging multi-threaded Python applications where understanding cross-thread timing and interactions is critical.
Files Changed
python/ray/dashboard/client/src/common/ProfilingLink.tsx- New profiling UI with format selectionpython/ray/dashboard/modules/reporter/profile_manager.py- Added chrometrace format supportpython/ray/dashboard/modules/reporter/reporter_head.py- New endpoint for trace viewerpython/ray/dashboard/client/public/trace-viewer/- Embedded Catapult trace viewersrc/ray/protobuf/reporter.proto- Added format field to protobufTest Plan
Screen.Recording.2026-03-12.at.7.19.20.PM.mov