Skip to content

Speed up transitive_dep_hash for singleton SCCs#21390

Merged
ilevkivskyi merged 1 commit into
python:masterfrom
KevinRK29:optimize-transitive-dep-hash
Jun 5, 2026
Merged

Speed up transitive_dep_hash for singleton SCCs#21390
ilevkivskyi merged 1 commit into
python:masterfrom
KevinRK29:optimize-transitive-dep-hash

Conversation

@KevinRK29

@KevinRK29 KevinRK29 commented May 1, 2026

Copy link
Copy Markdown
Collaborator

I noticed on a large codebase ~99.84% of SCCs are singletons.

So the two main changes are adding a singleton fast path and extracting graph[id] to be a local variable so that it does the lookup once per module rather than once per dependency,

The time in the transitive_dep_hash function drops 22%, and improved the overall warm run by 1%

@github-actions

github-actions Bot commented May 1, 2026

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@JukkaL JukkaL left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This adds some duplication, but a 1% perf improvement makes it worth it.

@KevinRK29 KevinRK29 marked this pull request as ready for review May 29, 2026 06:03
@KevinRK29 KevinRK29 changed the title [WIP] Speed up transitive_dep_hash for singleton SCCs Speed up transitive_dep_hash for singleton SCCs May 29, 2026
@ilevkivskyi ilevkivskyi merged commit 5e7e91b into python:master Jun 5, 2026
24 checks passed
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.

3 participants