Commit 021e9ee
Add async-aware profiling (#1006)
* Add async-aware profiling with --async flag
Adds await-time attribution so users can see how much wall-clock time
each `await` line spends waiting, displayed as pie charts in the GUI
and a new column in CLI output. Pies rotate clockwise so each row's
wedge starts where the previous row's ended. Also improves GPU pies
to use two-wedge (filled + remaining) rendering for consistency.
New modules: scalene_async.py (coroutine tracking, dual-strategy
instrumentation for 3.9+ polling and 3.12+ sys.monitoring),
replacement_asyncio.py (event loop shim). Extends statistics,
JSON output, CLI viewer, and GUI with async await data, concurrency
metrics, and task name attribution.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Remove unused type: ignore comment to fix mypy linter
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Fix ruff linter: use lowercase type annotations, remove quotes
Replace typing.Dict/List/Set/Tuple/Optional with builtins (safe
with from __future__ import annotations). Remove quoted forward
reference for RunningStats.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Add async profiling demo script
Example program for testing --async profiling with fast I/O,
slow I/O, CPU-bound, and mixed async workloads.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Cap async data structures to prevent unbounded memory growth
- Cap async_task_names sets at 100 entries per (file, line) to prevent
unbounded growth when programs create many uniquely-named tasks
- Cap _suspended_tasks dict at 10000 entries; clear when exceeded to
prune stale entries from tasks that yielded but never resumed
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Potential fix for code scanning alert no. 913: Empty except
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
* Potential fix for code scanning alert no. 914: Empty except
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
* Add developer guide docs for debugging and GUI patterns
Link new Scalene-Debugging.md and Scalene-GUI.md from CLAUDE.md,
documenting signal handler gotchas, async profiling debugging,
profile output pipeline, unbounded growth prevention, and GUI
column/chart patterns learned during async profiling work.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Enable async profiling by default
Async profiling has near-zero overhead for non-async code (one
frozenset lookup per signal, sys.monitoring callbacks never fire
without coroutines) and provides essential data for async code.
Users can disable with --no-async if needed.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>1 parent a29af53 commit 021e9ee
File tree
16 files changed
+1647
-915
lines changed- scalene
- scalene-gui
- tests
- test
16 files changed
+1647
-915
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
608 | 608 | | |
609 | 609 | | |
610 | 610 | | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
186 | 186 | | |
187 | 187 | | |
188 | 188 | | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
189 | 244 | | |
190 | 245 | | |
191 | 246 | | |
192 | | - | |
| 247 | + | |
| 248 | + | |
193 | 249 | | |
194 | 250 | | |
195 | 251 | | |
| |||
207 | 263 | | |
208 | 264 | | |
209 | 265 | | |
210 | | - | |
| 266 | + | |
211 | 267 | | |
212 | 268 | | |
213 | 269 | | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
214 | 275 | | |
215 | 276 | | |
216 | 277 | | |
217 | 278 | | |
218 | 279 | | |
219 | 280 | | |
220 | 281 | | |
221 | | - | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
222 | 285 | | |
223 | 286 | | |
224 | | - | |
| 287 | + | |
225 | 288 | | |
226 | 289 | | |
227 | | - | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
228 | 294 | | |
229 | 295 | | |
230 | 296 | | |
| |||
0 commit comments