[MERGE] log|less 590% to 727% faster

Aaron Bentley aaron.bentley at utoronto.ca
Sat Jun 17 23:36:56 BST 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

John Arbash Meinel wrote:
> Aaron Bentley wrote:

>>> I think I'm happy with 44 milliseconds for the first screenfull.  Merges
>>> shouldn't affect that very much.  Now if only we can pull down that
>>> startup time...

> Actually, we could just mess with the import of 'inspect' for 'copy'.
> 
> I just played with something, and I found a way that 'demandload()' can
> actually hack-into sys.modules so that other modules actually load a
> demandload version.
> 
> This semi-evil hack is available from here:
> http://bzr.arbash-meinel.com/misc/demandload_through_sys/

Your server appears to be down.

> Basically, you can do:
> 
> demandload(globals(), 'inspect foo bar')
> sys.modules['inspect'] = inspect
> sys.modules['foo'] = foo
> sys.modules['bar'] = bar
> 
> And then anyone else who tries to do 'import foo' actually gets the
> demandload object until they access an attribute.

IIRC, the issue is that we want to avoid importing tokenize, because of
its various and funky regexes.  Which we should be able to accomplish
using this method, right?

> If you look at my demandload branch of bzr, I played with it, and I now
> have the time for 'bzr --no-plugins root' down to 240 ms
> These are the overall timings:
> 
> 		rocks	root
> original	493	504
> demandload	148	281

Nicely done!

> And that is even without '--no-aliases' now that we aren't loading
> validate.py. (It still takes 35ms to load configobj, but that is down
> from 135ms).

That's still a significant fraction of startup time, so I guess we
should look at optimizing it.  Probably best to get the latest version,
and send our hackery upstream.

> So now that I've played with it some, we might actually want to
> considered adding demandload into the core.
> I realize it is a little evil to do my monkeypatching demandload, but it
> can shave off as much as 100ms from the startup time. Which can be 1/2
> the time we spend.

You can really feel the difference between .141s (hg --version) and .988
(bzr rocks).  I'm willing to be evil to get there.  We have test cases,
after all.

Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFElIQI0F+nu1YWqI0RAt9QAJ418eim+CCcXh+sMoGYFOhDbPrZEQCfUX6t
C2NWMttO4XEs9bUkqgedyB4=
=gWYS
-----END PGP SIGNATURE-----




More information about the bazaar mailing list