feat: skip Python runtime objects in callgrind#122
Conversation
Merging this PR will not alter performance
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ⚡ | WallTime | test_recursive_fibo_20 |
5.5 ms | 5.4 ms | +2.43% |
| ⚡ | WallTime | test_combination_sum[candidates0-8] |
12 µs | 11.4 µs | +5.25% |
| 👁 | WallTime | test_multiprocessing_map[1000] |
58.8 ms | 60.7 ms | -3.12% |
| 👁 | WallTime | test_color[graph0-3] |
30.1 µs | 31.4 µs | -4% |
| 👁 | WallTime | test_open_close_fd[100] |
882.8 µs | 919.1 µs | -3.94% |
| ⚡ | WallTime | test_fs_write[1000] |
18.7 µs | 18 µs | +4.15% |
| 👁 | WallTime | test_tcp_connection[1.1.1.1-53] |
1.1 ms | 1.1 ms | -4.32% |
| ⚡ | WallTime | test_n_queens_solve[board0] |
11.1 ms | 10.9 ms | +2.29% |
| 👁 | WallTime | test_open_knight_tour[1] |
4.3 µs | 4.4 µs | -2.26% |
| 👁 | WallTime | test_noop_lambda_decorated |
1.3 µs | 1.3 µs | -2.59% |
| 👁 | WallTime | test_multiprocessing_map[10000] |
89.9 ms | 108.8 ms | -17.36% |
| ⚡ | WallTime | test_match_word_pattern[aba-GraphTreesGraph] |
109.7 µs | 106.6 µs | +2.92% |
| ⚡ | WallTime | test_hamilton_cycle[graph0] |
26.1 µs | 25.4 µs | +2.82% |
| 👁 | WallTime | test_generate_all_combinations[5-4] |
10.1 µs | 10.6 µs | -5% |
| ⚡ | WallTime | test_sum_of_squares[sum_of_squares_sum_comprehension_product] |
198.5 µs | 192.9 µs | +2.93% |
| ⚡ | WallTime | test_fs_write[10000] |
44.6 µs | 41.8 µs | +6.62% |
| 👁 | WallTime | test_tcp_connection[google.com-443] |
1.2 ms | 1.2 ms | -3.64% |
| ⚡ | WallTime | test_fs_read[1000] |
878.4 ns | 850.2 ns | +3.31% |
| ⚡ | WallTime | test_hostname_resolution[google.com] |
397.4 µs | 388.6 µs | +2.26% |
| 👁 | WallTime | test_process_creation[cat /dev/null] |
5.3 ms | 5.4 ms | -2% |
| ... | ... | ... | ... | ... | ... |
ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.
Tip
Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.
Comparing cod-2654-flamegraph-doesnt-work-on-valgrind (3bbabe4) with master (d4d9dc6)
There was a problem hiding this comment.
Pull request overview
Adds a Callgrind/Valgrind client-request hook so CodSpeed can instruct Callgrind to ignore Python runtime object files (libpython + the python executable), reducing noise in Callgrind-derived flamegraphs.
Changes:
- Add a new C-extension method
callgrind_add_obj_skip(bytes_path)that issues a custom Valgrind client request. - Add Python helpers to resolve and register object-file paths (including
realpath) for skipping. - Invoke the skip logic during
InstrumentHooksinitialization to hide Python runtime frames by default.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/pytest_codspeed/instruments/hooks/instrument_hooks_module.c |
Exposes a new C-extension entrypoint that emits a Callgrind client request to skip an object file by path. |
src/pytest_codspeed/instruments/hooks/__init__.py |
Adds Python wrappers to call the extension and automatically skip libpython + the Python executable in Callgrind. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
GuillaumeLagrange
left a comment
There was a problem hiding this comment.
OLGTM, trusting you on how we retrieve the skipped path from python runtime
Adds a callgrind_add_obj_skip C extension function that emits the Valgrind client request VG_USERREQ__ADD_OBJ_SKIP (0x43540006), and a callgrind_skip_python_runtime() helper that skips libpython and the python executable. Called from InstrumentHooks.__init__ so Python runtime frames stop polluting the callgrind flamegraph (COD-2654).
GuillaumeLagrange
left a comment
There was a problem hiding this comment.
lgtm, discussed the callgrind.h and let's keep it this way temporarily
d7b50b1 to
3bbabe4
Compare
No description provided.