You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On a large python project, we recently updated our kernel to use a later version of Sphinx, and the build time increased from 44 seconds to over half an hour!
I believe the issue is related to the automodule mock imports: the slowdown only occurs when a mocked-out library is imported with the from ... import ... syntax as described below.
To Reproduce
Example module foo, and a mocked-out external dependency baz:
This leads to quite a slow build time of ~2 minutes, whereas it ought to build in about 5 seconds.
Environment info
OS: Linux-3.10
Python version: 3.8.5
Sphinx version: 3.2.1
Sphinx extensions: autodoc, autosummary, napoleon
Additional context
Bizarrely, any of these changes speeds up the build time to 5 seconds:
Writing import baz.BazClass rather than from baz import BazClass in foo.py
Commenting out from baz import BazClass in foo.py
Commenting out import IPython in foo.py
Making an actual module called baz available on the path and removing it from the autodoc_mock_imports list
I don't know why the IPython import is needed for the bug to appear. I have ipython v7.18.1 . In practice, none of our modules import IPython directly, but it is imported indirectly in several common libraries like ipykernel and ipywidgets.
On my real-life project, the build time is over half an hour. We mock out a lot of dependencies in the build script assigning a list of modules to autodoc_mock_imports. The vast majority of the documentation is automatically built from the module docstrings with autosummary.
Possibly related: Issue #7479 was closed by #7504 , slowdown apparently due to "recursive calls to inspect.unwrap() for Mocked objects".
The text was updated successfully, but these errors were encountered:
ghost
changed the title
Build 60x slower with sphinx v3.2.1 compared to v2.4.0, on large project
Build 60x slower with sphinx v3.2 compared to v2.4 when using autodoc_mock_imports
Oct 29, 2020
The mock objects set up via `autosummary_mock_imports` causes slow down
of autosummary stub generation because AttributeDocumenter falls into
infinite recursion call to unwrap decorators of mocked objects.
To avoid the trouble, this blocks unwrapping decorators of mocked
objects.
[EDIT: updated with reproducible example]
Describe the bug
On a large python project, we recently updated our kernel to use a later version of Sphinx, and the build time increased from 44 seconds to over half an hour!
I believe the issue is related to the automodule mock imports: the slowdown only occurs when a mocked-out library is imported with the
from ... import ...
syntax as described below.To Reproduce
Example module
foo
, and a mocked-out external dependencybaz
:foo.py:
index.rst :
config.py:
Build command:
This leads to quite a slow build time of ~2 minutes, whereas it ought to build in about 5 seconds.
Environment info
Additional context
Bizarrely, any of these changes speeds up the build time to 5 seconds:
import baz.BazClass
rather thanfrom baz import BazClass
in foo.pyfrom baz import BazClass
in foo.pyimport IPython
in foo.pyI don't know why the IPython import is needed for the bug to appear. I have ipython v7.18.1 . In practice, none of our modules import IPython directly, but it is imported indirectly in several common libraries like ipykernel and ipywidgets.
On my real-life project, the build time is over half an hour. We mock out a lot of dependencies in the build script assigning a list of modules to
autodoc_mock_imports
. The vast majority of the documentation is automatically built from the module docstrings with autosummary.Possibly related: Issue #7479 was closed by #7504 , slowdown apparently due to "recursive calls to inspect.unwrap() for Mocked objects".
The text was updated successfully, but these errors were encountered: