[Pythonmac-SIG] Slow loading of modules
Jack Jansen
Jack.Jansen@oratrix.com
Sun, 23 Feb 2003 23:12:40 +0100
On zaterdag, feb 22, 2003, at 12:30 Europe/Amsterdam, Doug Wyatt wrote:
> Try this:
>
> /python.exe -c "import Carbon.AE" & ; sample python.exe 10 10
>
> and then look at the sample log written to /tmp
Doug,
thanks a lot!!!! I looked at this, and it turns out most of the time is
spent in _dyld_link_module, and specifically in _resolve_undefineds and
_relocate_modules_being_linked.
On a hunch I disabled prebinding for the main executable, which I had
enabled only a couple of weeks ago. The results are staggering:
- With prebinding:
% time ./python.exe -c "pass"
0.130u 0.130s 0:00.62 41.9% 0+0k 24+3io 0pf+0w
% time ./python.exe -c "import _AE"
8.140u 0.170s 0:08.54 97.3% 0+0k 8+4io 0pf+0w
- Without prebinding:
% time ./python.exe -c "pass"
0.100u 0.130s 0:00.28 82.1% 0+0k 0+0io 0pf+0w
% time ./python.exe -c "import _AE"
1.130u 0.110s 0:01.39 89.2% 0+0k 0+1io 0pf+0w
I definitely do remember a speedup for the initial empty startup (I did
actually test that -prebind made a difference:-), so the fact that even
that is now worse may be an artifact of changes in site.py or something.
It appears that a program that does a lot of dynamic loading of code is
worse off when linked prebound. Does anyone have a good explanation for
this, or should I file an Apple bug report (even only suggesting that
they document this)?
--
- Jack Jansen <Jack.Jansen@oratrix.com>
http://www.cwi.nl/~jack -
- If I can't dance I don't want to be part of your revolution -- Emma
Goldman -