DEV Community

Cover image for Python 3.15 Profiling Finds web-edit’s Main CPU Hotspot
AI Feed
AI Feed

Posted on Originally published at aifeed.space

Python 3.15 Profiling Finds web-edit’s Main CPU Hotspot

A 15,296-stack profile tied most sampled activity to line-ending preservation and showed why all-thread capture matters for AnyIO workloads.

Simon Willison used Python 3.15’s built-in profiling.sampling tool on the unmodified web-edit application and found that preserving mixed line endings dominated a busy editing workload. The experiment demonstrates how the profiler can produce a flame graph and source heatmap without requiring changes to the application under examination.

The run recorded 15,296 CPU stacks. Willison reported that preserve_endings, the function responsible for retaining mixed line endings, appeared in 64.8% of them. Within this specific workload, that made line-ending preservation the most prominent source of sampled CPU activity identified by the profile.

The more detailed result pointed to SequenceMatcher.find_longest_match, which accounted for 38.3% of leaf samples. That narrows a substantial part of the observed cost from web-edit’s broader editing logic to sequence matching performed as part of preserving the original line-ending pattern.

Capturing every thread was essential to the result. According to Willison, 95.1% of the collected stacks came from AnyIO’s worker thread. A profile restricted to the main thread would therefore have excluded nearly all of the sampled activity and could have obscured the workload’s dominant hotspot.

For developers profiling asynchronous Python software, the experiment illustrates that collection scope can matter as much as the resulting visualization. A flame graph organizes sampled activity across call paths, while a source heatmap locates it in code; neither view can represent work that the profiler was not configured to capture.

Willison created the demonstrations by asking GPT-6 Astra Extra High in Codex to research the task and run the profiler against the PyPI release of web-edit. His page links to the resulting flame graph and heatmap, but provides no before-and-after optimization measurements. The published figures consequently establish a diagnostic finding for this run, not a verified application speedup.

Sources

Originally published by AI Feed: Python 3.15 Profiling Finds web-edit’s Main CPU Hotspot.

Top comments (0)