Skip to content

Optimize load_graph to avoid O(n**2) 'not ready' tracking - #20786

Merged
JukkaL merged 1 commit into
masterfrom
speed-up-process-graph
Feb 12, 2026
Merged

Optimize load_graph to avoid O(n**2) 'not ready' tracking#20786
JukkaL merged 1 commit into
masterfrom
speed-up-process-graph

Conversation

@JukkaL

@JukkaL JukkaL commented Feb 12, 2026

Copy link
Copy Markdown
Collaborator

Use a set instead of a list for tracking not ready SCCs, since set provides a O(1) remove operation, instead of O(n) for lists. In a large codebase, up to 37% of CPU was spent in the list.remove call when doing a small incremental run.

Use a set instead of a list for tracking not ready SCCs, since set
provides a O(1) remove operation, instead of O(n) for lists. In a large
codebase, up to 37% of CPU was spent in the list.remove call when
doing a small incremental run.
@JukkaL
JukkaL requested a review from ilevkivskyi February 12, 2026 11:55
@github-actions

Copy link
Copy Markdown
Contributor

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

@ilevkivskyi ilevkivskyi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good catch! Some things are only visible with a lot of files.

@JukkaL
JukkaL merged commit 157b87d into master Feb 12, 2026
23 checks passed
@JukkaL
JukkaL deleted the speed-up-process-graph branch February 12, 2026 13:18
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