-
Notifications
You must be signed in to change notification settings - Fork 16
SY-3420: CDP Console Profiling #1831
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
base: rc
Are you sure you want to change the base?
Conversation
…omatically open cpuprofile with speedscrope.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
11 files reviewed, 1 comment
|
Mentioned previously offline, another profiling avenue to explore is the using WebView2 remote debugging of the Tauri desktop app. However, this is only supported on Windows (Chromium) and not Linux or macOS (WebKit). A third alternative is rust native profiling, which was explored in the other SY-3420 pull request. |
emilbon99
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like there are some comments that are redundant
| from console.profiling.config import ProfilerConfig | ||
|
|
||
|
|
||
| class Profiler(Protocol): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the plan to shift this out of the console eventually? I.e. to use the same protocol for the go,C++ tooling?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the Profiler Protocol since it was dead code
A shared Python Protocol for Go/C++ profiling wouldn't provide meaningful value since they are fundamentally different.
- Console uses CDP WebSocket commands vs HTTP endpoints (net/http/pprof) vs system calls (perf)
- .cpuprofile (JSON) vs .pprof (protobuf) vs perf.data (binary)
- Dependencies: Playwright vs built-in Go vs platform tools
If we add C++ profiling, they could be separate implementations unified at the CLI level (e.g., synnax-profile console|server|driver) rather than via a shared abstract interface.
Issue Pull Request
Linear Issue
SY-3420
Description
Adds CDP profiling. Can be enabled for integration tests or run manually using the
console_pprof.pyscript, which mirrors to go profiling tool.To run manually, simply
cd integrationuv run console-pprof--heapwill save the heap snapshot--tracewill save the playwright traceThe script will automatically open the cpu profile using speedscope.

Greptile Summary
Added Chrome DevTools Protocol (CDP) profiling capabilities for Console integration tests and standalone use. The implementation provides CPU profiling, heap snapshots, and Playwright tracing with a clean, modular architecture.
Key Changes:
console.profilingpackage withCDPProfiler,ProfilerConfig,ProfileWriter, andProfilerprotocolConsoleCasetest base class with proper lifecycle management (tracing starts before page creation, CDP profiling after)console-pprofscript mirroring go pprof tool with automatic speedscope integration--console-profile,--console-trace, and--console-heapflagsintegration/profiles/directory (added to gitignore)Architecture:
The profiler uses CDP for CPU profiles and heap snapshots, and Playwright's built-in tracing API. The design properly separates configuration, client logic, and file writing with clean protocol definitions.
Issue Found:
console/case.py:30-37incorrectly states defaults areTruewhen they're actuallyFalseperconfig.py:41-47Confidence Score: 4/5
Important Files Changed
Sequence Diagram
sequenceDiagram participant User participant TestConductor participant ConsoleCase participant ProfilerConfig participant BrowserContext participant CDPProfiler participant CDPSession participant ProfileWriter User->>TestConductor: Run test with --console-profile TestConductor->>TestConductor: Set PLAYWRIGHT_CONSOLE_PROFILE=1 TestConductor->>ConsoleCase: setup() ConsoleCase->>ProfilerConfig: from_params(params) ProfilerConfig-->>ConsoleCase: config (cpu_profiling=True) ConsoleCase->>BrowserContext: new_context() BrowserContext-->>ConsoleCase: context alt Tracing enabled ConsoleCase->>BrowserContext: tracing.start() end ConsoleCase->>BrowserContext: new_page() BrowserContext-->>ConsoleCase: page ConsoleCase->>CDPProfiler: new(page, context, config) CDPProfiler-->>ConsoleCase: profiler ConsoleCase->>CDPProfiler: start_cdp_profiling() CDPProfiler->>BrowserContext: new_cdp_session(page) BrowserContext-->>CDPProfiler: cdp_session CDPProfiler->>CDPSession: send("Profiler.enable") CDPProfiler->>CDPSession: send("Profiler.start") Note over ConsoleCase: Test execution ConsoleCase->>CDPProfiler: stop(test_name) alt Heap snapshot enabled CDPProfiler->>CDPSession: send("HeapProfiler.enable") CDPProfiler->>CDPSession: on("HeapProfiler.addHeapSnapshotChunk") CDPProfiler->>CDPSession: send("HeapProfiler.takeHeapSnapshot") CDPSession-->>CDPProfiler: heap chunks CDPProfiler->>ProfileWriter: write_heap_snapshot() ProfileWriter-->>CDPProfiler: heapsnapshot path end CDPProfiler->>CDPSession: send("Profiler.stop") CDPSession-->>CDPProfiler: profile data CDPProfiler->>ProfileWriter: write_cpu_profile() ProfileWriter-->>CDPProfiler: cpuprofile path alt Tracing enabled CDPProfiler->>BrowserContext: tracing.stop(path) BrowserContext-->>CDPProfiler: trace.zip path end ConsoleCase->>CDPProfiler: close() CDPProfiler->>CDPSession: detach()