Skip to content

Avoid quadratic re-sorting of consecutive target and index nodes - #14612

Open
larsoner wants to merge 3 commits into
sphinx-doc:masterfrom
larsoner:short-circuit
Open

Avoid quadratic re-sorting of consecutive target and index nodes#14612
larsoner wants to merge 3 commits into
sphinx-doc:masterfrom
larsoner:short-circuit

Conversation

@larsoner

Copy link
Copy Markdown
Contributor

Purpose

Avoid re-sorting nodes that are already sorted. This takes a doc build for my project from 5m40s to 4m33s by taking _reorder_index_target_nodes time from 69.4s to 2.5s.

We include a names.inc with hundreds of entries in rst_prolog. I'm going to independently mitigate in MNE by only including that file where it's needed and trim those included in rst_prolog as well, but I imagine there are other projects that have these sorts of large link inclusions, and it would be nice not to penalize having too many links so heavily.

References

None

AI Disclosure

Claude Fable 5 was used to diagnose the problem (py-spy on MNE-Python docs) and write the fix. I reviewed and validated the implementation.

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

Nice! I feel like this change deserves a CHANGES.rst entry

@larsoner

Copy link
Copy Markdown
Contributor Author

Okay, pushed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants