Skip to content
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

Make sure parallel mode can be used with sphinx-automodapi #38

Closed
wants to merge 114 commits into from

Conversation

astrofrog
Copy link
Member

@astrofrog astrofrog commented Sep 30, 2017

Currently sphinx can't run in parallel mode when using sphinx-automodapi because extensions have to declare they are parallel-safe. However, I discovered that smart_resolver is not parallel-safe since it relies on populating a global dictionary which doesn't get communicated back to the main process. Instead I've implemented a file-based approach for the dictionaries, with one file per process.

For the astropy docs, using parallel mode -j4 on a 4-core mac laptop I get a speedup of 40%:

real	4m45.616s
user	12m12.225s
sys	0m50.415s

compared to the serial mode:

real	6m37.317s
user	5m51.115s
sys	0m28.985s

I need to investigate why the speedup isn't more significant.

astrofrog and others added 30 commits November 1, 2016 15:32
… catch cases where it is used inside a code block as an example
Fix encoding error with automodapi_writereprocessed and py2
…luding reference output files that can be compared with the input files.
…ue to the :no-main-docstr: option), the autosummary directive did not recognize that it was in the correct module.
astrofrog and others added 22 commits May 29, 2017 15:59
Fix behavior of :inherit-members: when multiple automodapi directives are present
Use generic version of setup_conda rather than OS dependent
Adding python3.6 to appveyor testing
…s when locale is C (restricting the charset to ASCII)
Add a test configuration with a default ASCII locale
@astrofrog
Copy link
Member Author

@eteq - since you have done a lot with the sphinx extensions in the past, could you review this?

Copy link
Member

@eteq eteq left a comment

Choose a reason for hiding this comment

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

I didn't fully review the logic, because my second inline comment suggests what might be a substantial re-implementation. Can take another look if you had a reason for not using the event (or want to use the event technique instead).

@@ -110,6 +117,8 @@ def test_run_full_case(tmpdir, case_dir):
path_relative = os.path.relpath(path_reference, output_dir)
path_actual = os.path.join(docs_dir, path_relative)
assert os.path.exists(path_actual)
actual = io.open(path_actual, encoding='utf8').read()
reference = io.open(path_reference, encoding='utf8').read()
with io.open(path_actual, encoding='utf8') as f:
Copy link
Member

Choose a reason for hiding this comment

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

I could be wrong here, but I think this might cause trouble in locales where UTF8 doesn't come out as a default? Might it be sufficient to just do a Byte-wise comparison to sidestep the encoding problem?

from docutils.nodes import literal, reference

# NOTE: This extension originally used a dictionary stored in app.env to keep
Copy link
Member

Choose a reason for hiding this comment

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

This whole approach seems a bit problematic, as it depends on file systems and sort of implementation details. Is there a reason you didn't try using theevent-env-merge-info event to do the parallel gathering (http://www.sphinx-doc.org/en/stable/extdev/appapi.html#event-env-merge-info)? I thought it was meant to solve exactly this problem? (Although I've not used it myself...)

@astrofrog
Copy link
Member Author

This was closed as the master branch was updated to include history. I'll need to do a new implementation based on @eteq's comments anyway.

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.

7 participants