[MERGE][bug #300289] Avoid unnecessary work

John Arbash Meinel john at arbash-meinel.com
Tue Nov 25 18:56:09 GMT 2008


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

John Arbash Meinel wrote:
> I haven't fully understood why, but when branching from a stacked branch
> into a standalone branch, it turns out that this "set.difference_update"
> was a significant portion of the overall time.
> 
> Adding this shortcut drops the time for "bzr branch stacked standalone"
> from 3m9s down to 1m45s (approx 40% of the total time.)
> 
> My guess is that we are doing something like has_key() on the target
> index (which is being built). (I see 203k calls to
> BTreeBuilder.iter_entries().) Also, in a bit of testing that I did, it
> seems that set.difference_update() *always* iterates the full target,
> even when source is small.
> 
> For example "small_set.difference_update(large_set)" is relatively slow.
> (Of course, calling it 172k times doesn't help.)
> 
> I'm still investigating more fixes for stacked branches, but this was a
> small patch that made a big difference.
> 
> John
> =:->

I'm attaching a different way to fix this, which may seem a bit more
logical.

Basically, we just did "keys.intersection(self._keys)" in order to
figure out what we should return from the in-memory index. We can save
that information, and use that as part of the "difference_update". We
don't technically need the shortcut return anymore, but I did see a
few-second difference with it in. (1m47s versus 1m51s, not huge, but why
do the work if we aren't going to use it.)

This version will also scale better if we ever *do* have to write out
the keys to disk.

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkksSkkACgkQJdeBCYSNAANUUwCfY74YfgLtBtZjYOsksbP83xK+
YP0An2LDxsndanxzg06JBvsoy1ZQtoIF
=Nznt
-----END PGP SIGNATURE-----
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: builder_iter_entries.patch
Url: https://lists.ubuntu.com/archives/bazaar/attachments/20081125/b8adc9a9/attachment-0001.diff 


More information about the bazaar mailing list