Open Bug 1775197 Opened 3 years ago Updated 2 years ago

mach python has a large overhead

Categories

(Firefox Build System :: Mach Core, defect, P3)

defect

Tracking

(Not tracked)

People

(Reporter: glandium, Unassigned)

Details

Attachments

(1 file)

STR:

$ echo > test.py
$ time ./mach python test.py
real	0m0.709s
user	0m0.570s
sys	0m0.130s

For comparison:

$ time python3 test.py
real	0m0.009s
user	0m0.009s
sys	0m0.001s

It's harder to measure with other commands, but this likely affects other commands.

$ (export MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE=none; time ./mach python test.py)
real	0m0.482s
user	0m0.383s
sys	0m0.089s

The severity field is not set for this bug.
:ahochheiden, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(ahochheiden)
Severity: -- → S3
Flags: needinfo?(ahochheiden)
Priority: -- → P3

I think this may have gotten worse since the bug was filed (for my Ubuntu 22 machine):

mfroman@moz:~/mozilla/moz-central$ time python3 -c 'print("done")'
done

real	0m0.036s
user	0m0.031s
sys	0m0.007s
mfroman@moz:~/mozilla/moz-central$ time ./mach python -c 'print("done")'
done

real	0m10.082s
user	0m8.701s
sys	0m2.042s

In both cases, the "done" output appears quickly, albeit slightly slower with ./mach python. However, the ./mach python version spends a great deal of time after "done" output.

$ time ./mach python -c 'print("done")'
done

real	0m0.835s
user	0m0.681s
sys	0m0.176s

You may want to capture a profile of what it's doing (./mach --profile-command python -c 'print("done")')

mfroman@moz:~/mozilla/moz-central$ ./mach --profile-command python -c 'print("done")'
done
Mach command profile created at "/home/mfroman/mozilla/moz-central/mach_profile_python.cProfile". To visualize, use snakeviz:
python3 -m pip install snakeviz
python3 -m snakeviz mach_profile_python.cProfile

Interesting note: the times reported on my MacBook Pro are much closer to glandium's times.

MJF-MacBookPro:moz-central mfroman$ time python3 -c 'print("done")'
done

real	0m0.029s
user	0m0.013s
sys	0m0.012s
MJF-MacBookPro:moz-central mfroman$ time ./mach python -c 'print("done")'
done

real	0m0.830s
user	0m0.936s
sys	0m0.306s

(In reply to Michael Froman [:mjf] from comment #5)

Created attachment 9323404 [details]
mach_profile_python.cProfile

erf, the profile itself only accounts for 0.031s. I guess whatever is taking forever on your machine is happening after the profiler is disabled.

I'll investigate my machine after I return from PTO (Mar 22), but I cloned a separate copy of m-c and the times match glandium's times. So there is something in that copy of the repo or obj-dir that causing the issue (which interestingly is getting progressively worse).

(In reply to Michael Froman [:mjf] from comment #8)

I'll investigate my machine after I return from PTO (Mar 22), but I cloned a separate copy of m-c and the times match glandium's times. So there is something in that copy of the repo or obj-dir that causing the issue (which interestingly is getting progressively worse).

What didn't help:
./mach clobber --full ; hg purge --all

What did help:
hg pull central ; hg update tip ; ./mach bootstrap --application=browser

Sorry for the noise!

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: