-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Slow startup of nrniv -python
[find libpython]
#564
Comments
Not a solution but an expected observation. Launching nrnpyenv.sh will be avoided if there is already a |
It has always been a puzzle to me why python just does not robustly give the path of its library via sys. |
@nrnhines : This sounds reasonable to me to avoid the current problem with the wheel. |
@nrnhines : here are the details that you asked on Slack message:
I have added
So the culprits here are:
those took long time to finish. If I do those manually on command line:
If I use sysconfig to find out library path:
|
I tried two experiments. Both, failures. First tried the C-API function Py_GetPythonHome(), but, checking it after python3.7.6 was fully initialized, it returned None (it appears to only return the value of the PYTHONHOME environment variable). So the most robust determination of PYTHONHOME I know so far is the value of sys.base_prefix which was introduced in python 3.3.
So the simplest determination of PYTHONHOME appears to be sys.base_prefix if it exists and otherwise fall back to sys.prefix and hope for the best. The second failure was to try to use dladdr to determine the python library path. This only works if python is not a static executable (which it often is, even though there is also a libpython...so). For example, just for experimental purposes, I repurposed a nrn.Section method so that
and it prints
This is also why I never got much benefit from ldd or otool (also the latter does not exist on mac unless command line tools are installed) Note the size of python and libpython are
|
@nrnhines : I would go for this simple solution. I think in practice it should cover almost all cases (?) |
I'm very puzzled that even though
does not mention libpython. When one launches it and uses lsof to determine the open files, it is listed!
|
This was investigated. As far as I remember, slow startup of wheel was fixed. |
On some setups, mainly with network filesystems, using PYTHON_DYNAMIC, launching
nrniv -python
is extremely slow, taking more than 1 minute. This was observed in the neurosim cluster.The problem boils down to the
find (...) libpython
innrnpyenv.sh
and its recursive behavior. However, if one uses-maxdepth 1
(See PR #560 ) in some cases libpython is not found, like in the Travis CI Python.By attempting to create a similar setup one could observe that some Pythons put libraries inside a folder
x86_64-linux-gnu
. Such directory could potentially be know fromThat is potentially since this is drawn from pure observation, without formal documentation.
Instead of such quick-patch, we could evaluate other solutions eventually more robust, namely:
DYLD_PRINT_LIBRARIES
:LD_DEBUG=files
.For discussion, a potentially very clean solution but disruptive , would be to replace a call to
nrniv -python
withpython
via exec.The text was updated successfully, but these errors were encountered: