- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cache Publisher
objects to speed up Sphinx
#10337
Conversation
6b6a58f
to
0495ad7
Compare
0495ad7
to
ab3b3e2
Compare
CI passed. A |
sphinx/registry.py
Outdated
@@ -461,6 +466,41 @@ def get_envversion(self, app: "Sphinx") -> Dict[str, str]: | |||
envversion['sphinx'] = ENV_VERSION | |||
return envversion | |||
|
|||
def create_publisher(self, app: "Sphinx", filename: str) -> Publisher: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I considers registry is a mere storage of components. So it should not have "features" as possible. So I'd like to move this sphinx.io
back again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How's the current?
A
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your update. I prefer the idea of create_publisher()
. +1 for this.
sphinx/registry.py
Outdated
@@ -461,6 +466,41 @@ def get_envversion(self, app: "Sphinx") -> Dict[str, str]: | |||
envversion['sphinx'] = ENV_VERSION | |||
return envversion | |||
|
|||
def create_publisher(self, app: "Sphinx", filename: str) -> Publisher: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your update. I prefer the idea of create_publisher()
. +1 for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I commented a few, but it should not prevent merging this into the 5.0 release. So I'd like to merge this before feature freeze and refactor it after the beta release.
@tk0miya I merged the function into
I added a longer comment -- Docutils' publisher reuses the settings object, but in A |
CI now passing. A |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with nits.
# The settings object is reused by the Publisher for each document. | ||
# Becuase we modify the settings object in ``write_doctree``, we | ||
# need to ensure that each doctree has an independent copy. | ||
doctree.settings = doctree.settings.copy() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for updating comment. I understand what you're going. I think it's much better to move this into write_doctree()
.
Thank you for your work. This must be the best improvement in 5.0! |
I don't think this is a big enough change to justify being a "feature". It does seem to be quite a big speed-up though (at least 20% faster).
Tests with
builddoc.yml
show 55s on5.x
and 35s on this branch (~36% faster).Tests on the main CI (Python 3.10, ubuntu) show 211s on
5.x
and 160s on this branch (~24% faster).A
Feature or Bugfix