Draft
Conversation
- Add profiling module to capture individual stack traces - Add DAP protocol schemas for startProfiling/stopProfiling requests - Add pydevdProfilingData event for streaming samples - Implement handlers in adapter and server - Each sample is now a stack (array of frames) for flame graphs Co-authored-by: vilterp <7341+vilterp@users.noreply.github.com>
- Replace sys._current_frames() with proper Python profiling API - Use sys.setprofile() to capture stacks during execution - Time-based sampling within profile callback - More accurate call stacks aligned with Python's profiling model Co-authored-by: vilterp <7341+vilterp@users.noreply.github.com>
- Fix wait_for_next API usage in tests - Add comprehensive PROFILING.md documentation - Document sample format, API, and usage examples Co-authored-by: vilterp <7341+vilterp@users.noreply.github.com>
- Add profiling_example.py demonstrating the feature - Fix flake8 linting issues (remove unused imports, fix indentation) - Clean up code style Co-authored-by: vilterp <7341+vilterp@users.noreply.github.com>
- Comprehensive summary of profiling feature implementation - Documents all changes, design decisions, and architecture - Provides next steps for VSCode integration - Ready for review and merge Co-authored-by: vilterp <7341+vilterp@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add profiling support for debug sessions in VSCode
Add live profiling support with DAP streaming for flame graph visualization
Feb 3, 2026
- Add frame ID deduplication to reduce data transfer by 75-90% - Use dataclasses (StackFrame, ProfilingData, ProfilingResult) instead of dicts - Events now send newFrames (ID->frame map) and samples (arrays of IDs) - Client maintains accumulated frame map to reconstruct full stacks - Update schema to include newFrames field - Update documentation with new format and deduplication details - Test verified: deduplication working correctly Co-authored-by: vilterp <7341+vilterp@users.noreply.github.com>
- Add duration field showing sampling window length in milliseconds - Track batch_start_time and calculate duration on each send - Update ProfilingData dataclass with duration field - Update DAP schema to include duration - Update documentation and tests to include duration - Test verified: duration shows correct batch window time (~150ms for 10 samples) Co-authored-by: vilterp <7341+vilterp@users.noreply.github.com>
Copilot
AI
changed the title
Add live profiling support with DAP streaming for flame graph visualization
Add live profiling with frame deduplication and DAP streaming
Feb 3, 2026
- Rename class ProfilingData to SampleBatch in profiling.py - Update all type hints and callbacks to use SampleBatch - Update variable name profiling_data to sample_batch - Update documentation in PROFILING.md and PROFILING_IMPLEMENTATION.md - All tests pass and linting is clean Co-authored-by: vilterp <7341+vilterp@users.noreply.github.com>
Copilot
AI
changed the title
Add live profiling with frame deduplication and DAP streaming
Rename ProfilingData to SampleBatch
Feb 3, 2026
- Create VSCODE_INTEGRATION.md with comprehensive guide - Document VSCode Python extension repository location - Provide implementation roadmap for VSCode integration - Include code examples and UI requirements - Add reference links to README.md and PROFILING.md Co-authored-by: vilterp <7341+vilterp@users.noreply.github.com>
Copilot
AI
changed the title
Rename ProfilingData to SampleBatch
Add VSCode integration guide for profiling feature
Feb 3, 2026
Copilot
AI
changed the title
Add VSCode integration guide for profiling feature
Add live profiling via DAP with frame deduplication
Feb 3, 2026
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.
Implements profiling support for debugpy, enabling live performance analysis during debug sessions. Samples are streamed over DAP as individual call stacks suitable for flame graph visualization.
Core Implementation
src/debugpy/server/profiling.py): Usessys.setprofile()for accurate call stack capture at 10ms intervals (configurable)startProfiling/stopProfilingrequests,profilingDataevent streamStackFrame,SampleBatch,ProfilingResult- no dicts except dynamic collectionsFrame Deduplication Protocol
Reduces bandwidth 75-90% by sending frames once, then referencing by ID:
{ "newFrames": { "12345": {"file": "/app/main.py", "line": 10, "function": "main"}, "67890": {"file": "/app/utils.py", "line": 42, "function": "calc"} }, "samples": [[12345, 67890], [12345]], "sampleCount": 2, "duration": 150.5 }Frame IDs are stable hashes of (file, line, function). Client accumulates frame map, reconstructs full stacks from IDs.
Client Integration Pattern
Files
New:
src/debugpy/server/profiling.py- profiler implementationtests/debugpy/test_profiling.py- test suitedoc/PROFILING.md- API referenceVSCODE_INTEGRATION.md- IDE integration guideModified:
src/debugpy/_vendored/pydevd/_pydevd_bundle/_debug_adapter/pydevd_schema.py- protocol schemassrc/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_process_net_command_json.py- request handlerssrc/debugpy/adapter/{clients,servers}.py- adapter integrationVSCode Python extension integration documented in
VSCODE_INTEGRATION.md(repo: microsoft/vscode-python).Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.