Skip to content

Fix: sysmon falls back to ctrace when branch=True (issue #2172)#2175

Open
Supull wants to merge 4 commits into
coveragepy:mainfrom
Supull:fix/sysmon-branch-perf-2172
Open

Fix: sysmon falls back to ctrace when branch=True (issue #2172)#2175
Supull wants to merge 4 commits into
coveragepy:mainfrom
Supull:fix/sysmon-branch-perf-2172

Conversation

@Supull

@Supull Supull commented May 21, 2026

Copy link
Copy Markdown

Fixes #2172

When using branch coverage on Python 3.14+, sysmon ends up being slower than ctrace. This is because sysmon's big advantage is disabling events after the first time a line is seen. But for branch coverage it cannot do that, since the same line can be reached from many different places in the code. So it keeps firing a Python callback on every single execution, which is actually slower than ctrace's C-level trace function.

Fix: when branch=True and the user has not explicitly chosen a core, quietly fall back to ctrace instead. If you explicitly set COVERAGE_CORE=sysmon you still get sysmon. This only affects the default behavior.

)

When using branch coverage on Python 3.14+, sysmon ends up being
slower than ctrace. This is because sysmon's big advantage is
disabling events after the first time a line is seen. But for
branch coverage it cannot do that, since the same line can be
reached from many different places in the code. So it keeps firing
a Python callback on every single execution, which is actually
slower than ctrace's C-level trace function.

Fix: when branch=True and the user has not explicitly chosen a
core, quietly fall back to ctrace instead. If you explicitly set
COVERAGE_CORE=sysmon you still get sysmon. This only affects the
default behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sysmon is slower than ctrace on 3.14 for the Scrapy test suite

1 participant