Open mottosso opened 5 years ago
Not particularly useful, as Rez launches an opaque subprocess taking the vast majority of time.
220 seconds to resolve 2 requests, in a repository of 200 packages with a total of 2,000 versions, on a local SSD drive on Windows 10
$ rez env a b
Not much to see here. The subprocess is the one doing all the work.
Something interesting appears.
pyparsing
, taking up a whopping 10 secondsfilesystem
locale
ntpath
shutil
logging
os
at 6.98 secondsconfig
and handlers
both coming from the logging
package.
formatting
socket
warnings
handlers
inspect
tempfile
config
collections
platform_
Could we leverage Python's -O
flag for this?
import time
t0 = time.time()
if __debug__:
print("Zzzzzzzzzz...")
time.sleep(1)
print("Finished in %.2f s" % (time.time() - t0))
This script takes ~1 second to run, unless you pass -O
.
$ python temp.py
Finished in 1.00 seconds
$ python -O temp.py
Finished in 0.00 seconds
Apparently, anything under if __debug__
is removed from the resulting source code prior to being run. Along with also removing assert
statements. Or at the very least __debug__
is guaranteed to be available regardless of -O
and set to False with -O
which is the next best thing.
My guess is that if we host calls to print and log statements during resolve under a if __debug__
we should see a significant performance improvement.
If that works, then an install could automatically yield .pyo
files as opposed to .py
or .pyc
, and a user on an install without those could create them himself by simply passing -O
to Python.
In preparation for patching bottlenecks, one at a time, here is some preliminary (production) data, from 200 packages, 2,000 versions, 30 GB, over an NFS share on Windows 10.
10+ seconds spent in total for
rez env
.