From cd795195d53ae006ac70541c2a856c8212b40b63 Mon Sep 17 00:00:00 2001 From: Marti Bolivar Date: Wed, 13 Feb 2019 14:04:11 -0700 Subject: [PATCH] doc: fix parallel builds 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 --- doc/extensions/only/eager_only.py | 12 +++++++++++- doc/extensions/zephyr/html_redirects.py | 7 +++++++ doc/extensions/zephyr/link-roles.py | 7 +++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/doc/extensions/only/eager_only.py b/doc/extensions/only/eager_only.py index 70b21b41189ce0..dcdec26fa8a70f 100644 --- a/doc/extensions/only/eager_only.py +++ b/doc/extensions/only/eager_only.py @@ -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 [] @@ -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, + } diff --git a/doc/extensions/zephyr/html_redirects.py b/doc/extensions/zephyr/html_redirects.py index 9bd2dd484c5e75..7f90b0af83ab5f 100644 --- a/doc/extensions/zephyr/html_redirects.py +++ b/doc/extensions/zephyr/html_redirects.py @@ -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): diff --git a/doc/extensions/zephyr/link-roles.py b/doc/extensions/zephyr/link-roles.py index 04b627b1ab376b..ecb29398c4cc8a 100644 --- a/doc/extensions/zephyr/link-roles.py +++ b/doc/extensions/zephyr/link-roles.py @@ -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=[]):