Open Bug 1460678 Opened 6 years ago Updated 1 year ago

Improve |mach doc| performance

Categories

(Developer Infrastructure :: Source Documentation, enhancement)

enhancement

Tracking

(Not tracked)

REOPENED

People

(Reporter: ahal, Assigned: Sylvestre)

References

(Blocks 1 open bug)

Details

(Keywords: leave-open)

Attachments

(5 files, 2 obsolete files)

I think there might be some low-hanging fruit to improve the |mach doc| performance (which is generally really terrible).

A couple ideas:
1. Upgrade sphinx to latest version
2. Use sphinx's -J argument (not sure how much of an impact this has)
3. Build regular and python API docs in parallel (these are two separate sphinx invocations on unrelated directories that happen serially)
4. Be smarter about caching results and only re-building what we need to. Sphinx normally does this automatically, but since we move the entire doctree from the srcdir->objdir each time, it thinks everything has always changed. This might be better off in a follow-up.
Another idea:
Make a sphinx build backend so we don't need to re-read moz.build each time. Rebuilds triggered via the livereload server already cache this result however, so it might not be as worthwhile.
Version: Version 3 → 3 Branch

Hi Andrew,

For 1, I guess the sphinx is already the latest version i.e. 1.8.5 as installed using pipenv
For 2, Can you please link me to the argument you are referring.
For 3, I was thinking of using ThreadPoolExecutor in light of ProcessPool. Am I wandering right?

Hi Anurag, sorry I missed your comment.

This bug is currently earmarked for a GSoC internship (he may be about to start working on it shortly). But since there are multiple things to work on here, maybe we could split it out into smaller bugs and divide things up in a way that won't cause you to step on each other's toes. So just hang on for now if you're still interested and I'll let you know.

No problem and yes I am still interested. Please let me know, if you have anything I can work on. :D

Assignee: nobody → shivams2799
Assignee: shivams2799 → nobody

:ahal , can you please review D41062.
:championshuttler, I removed the "checkin-needed". Please add it after the patch is r+ .

Flags: needinfo?(ahal)
Keywords: checkin-needed

Narcis, thanks. It will be reviewed soon. Clearing ni for :ahal.

Flags: needinfo?(ahal)
Assignee: nobody → shivams2799
Status: NEW → ASSIGNED
Keywords: leave-open
Pushed by ahalberstadt@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/07e30c57a8e6
Improve mach doc performance,  use sphinx's -J argument. r=ahal
Attachment #9083767 - Attachment is obsolete: true
Status: ASSIGNED → NEW
Assignee: shivams2799 → nobody
  1. Upgrade sphinx to latest version

Moving from 1.8.5 => 2.2.2 isn't improving much the time.

./mach doc --no-serve  125,26s user 10,34s system 158% cpu 1:25,70 total

=>

./mach doc --no-serve  122,69s user 8,54s system 184% cpu 1:11,11 total

Bug 1601612 for the implementation

The leave-open keyword is there and there is no activity for 6 months.
:rstewart, maybe it's time to close this bug?

Flags: needinfo?(rstewart)
Status: NEW → RESOLVED
Closed: 4 years ago
Flags: needinfo?(rstewart)
Resolution: --- → WONTFIX

Actually, we will work on that.
emil, gsoc student, might have some time to have a look.

Status: RESOLVED → REOPENED
Resolution: WONTFIX → ---

To generate this:

diff --git a/mach b/mach
--- a/mach
+++ b/mach
@@ -65,17 +65,17 @@ py2commands="
 
 run_py() {
     # Try to run a specific Python interpreter. Fall back to the system
     # default Python if the specific interpreter couldn't be found.
     py_executable="$1"
     shift
     if which "$py_executable" > /dev/null
     then
-        exec "$py_executable" "$0" "$@"
+        exec "$py_executable" -m cProfile -s ncalls "$0" "$@"
     elif [ "$py_executable" = "python2.7" ]; then
         exec python "$0" "$@"
     else
         echo "This mach command requires $py_executable, which wasn't found on the system!"
         exit 1
     fi
 }

And run with

./mach -v doc --no-serve &> foo2.log

To generate better infos:
use:

        exec "$py_executable" -m cProfile -o machdoc.cprof -s ncalls "$0" "$@"

in mach doc

then

pyprof2calltree -k -i machdoc.cprof

More on my buddy website:
https://julien.danjou.info/guide-to-python-profiling-cprofile-concrete-case-carbonara/

Is there still something that needs to be fixed on this bug that i could lay my hands on?

Flags: needinfo?(sledru)
Flags: needinfo?(ahal)

Perhaps you could fix some of the warnings that show up with ./mach doc (ideally there shouldn't be any warnings). There aren't any bugs on file, but you can file one once you've picked a few warnings to tackle.

Flags: needinfo?(sledru)
Flags: needinfo?(ahal)

It is getting worse and worse!

I run the python profiler. It seems that, for a normal doc build, we are calling 981 869 277 times a function called "sentry_patched_popen_communicate".

So, disabling sentry (export DISABLE_TELEMETRY=1) dropped the time from
./mach doc --no-serve &> foo.log 383,58s user 141,69s system 64% cpu 13:37,21 total
to
./mach doc --no-serve &> foo.log 136,96s user 7,55s system 144% cpu 1:40,21 total

Assignee: nobody → sledru
Version: 3 Branch → unspecified
Pushed by sledru@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/925cdf01fd85
doc: Disable sentry as it adds significant overhead r=mhentges
https://hg.mozilla.org/integration/autoland/rev/775e23b5bf52
doc: ride along bump sentry r=mhentges

The leave-open keyword is there and there is no activity for 6 months.
:Sylvestre, maybe it's time to close this bug?
For more information, please visit auto_nag documentation.

Flags: needinfo?(sledru)

Yeah, still slow... but I don't have a better solution for now

Flags: needinfo?(sledru)
Product: Firefox Build System → Developer Infrastructure
Severity: normal → S3

to profile it:
python3 -m cProfile -o machdoc.cprof -s ncalls mach doc
python3 -m snakeviz machdoc.cprof
or
pyprof2calltree -k -i machdoc.cprof

Duplicate of this bug: 1749472

Comment on attachment 9325204 [details]
Bug 1460678 - upgrade sphinx to version 5 r=#firefox-source-docs-reviewers

Revision D173704 was moved to bug 1824659. Setting attachment 9325204 [details] to obsolete.

Attachment #9325204 - Attachment is obsolete: true
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: