Skip to content

Speed up transitive_dep_hash for singleton SCCs#21390

Open
KevinRK29 wants to merge 1 commit into
python:masterfrom
KevinRK29:optimize-transitive-dep-hash
Open

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

Conversation

@KevinRK29
Copy link
Copy Markdown
Collaborator

@KevinRK29 KevinRK29 commented May 1, 2026

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
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

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

Copy link
Copy Markdown
Collaborator

@JukkaL JukkaL left a comment

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
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.

2 participants