Skip to content

Commit

Permalink
doc: fix parallel builds
Browse files Browse the repository at this point in the history
Several of our extensions don't declare they are parallel read or
write safe. Upon inspection, they are.

Not declaring parallel read safety defeats a lot of the speed ups that
are possible when using SPHINXOPTS="-j=auto", so mark the extensions
safe and get the performance back.

Signed-off-by: Marti Bolivar <[email protected]>
  • Loading branch information
Marti Bolivar authored and carlescufi committed Mar 29, 2019
1 parent 74a2d2b commit cd79519
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
12 changes: 11 additions & 1 deletion doc/extensions/only/eager_only.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def run(self, *args):
# Evaluate the condition eagerly, and if false return no nodes right away
env = self.state.document.settings.env
env.app.builder.tags.add('TRUE')
#print(repr(self.arguments[0]))

if not env.app.builder.tags.eval_condition(self.arguments[0]):
return []

Expand All @@ -44,3 +44,13 @@ def run(self, *args):

def setup(app):
directives.register_directive('only', EagerOnly)

# The tags.add call above is setting tags.tags['TRUE'] = True.
# The operation is idempotent and will have taken effect before
# the next eval_condition() which may rely on it so this is thread
# safe both for read and writes (all other operations are local to
# the local nodes variable).
return {
'parallel_read_safe': True,
'parallel_write_safe': True,
}
7 changes: 7 additions & 0 deletions doc/extensions/zephyr/html_redirects.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ def setup(app):
app.add_config_value('html_redirect_pages', [], 'html')
app.connect('build-finished', create_redirect_pages)

# Since we're just setting up a build-finished hook, which runs
# after both reading and writing, this extension is safe for both.
return {
'parallel_read_safe': True,
'parallel_write_safe': True,
}


def create_redirect_pages(app, docname):
if not isinstance(app.builder, StandaloneHTMLBuilder):
Expand Down
7 changes: 7 additions & 0 deletions doc/extensions/zephyr/link-roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ def setup(app):
app.add_role('zephyr_file', autolink('{}/blob/{}/%s'.format(baseurl, rev)))
app.add_role('zephyr_raw', autolink('{}/raw/{}/%s'.format(baseurl, rev)))

# The role just creates new nodes based on information in the
# arguments; its behavior doesn't depend on any other documents.
return {
'parallel_read_safe': True,
'parallel_write_safe': True,
}


def autolink(pattern):
def role(name, rawtext, text, lineno, inliner, options={}, content=[]):
Expand Down

0 comments on commit cd79519

Please sign in to comment.