[MERGE] Simple optimization of common annotate case
John Arbash Meinel
john at arbash-meinel.com
Thu Jan 24 23:04:35 GMT 2008
I've been trying to improve 'bzr annotate' performance. It turns out
there are 2 pieces to it. The first is that we still pay for
"get_revision_id_to_revno_map()" which is slower with packs as it is a
whole-history operation. If you do 'bzr annotate --show-ids' then it
avoids that code, so I started there.
What I found was that "reannotate()" was actually the big slowdown.
Something about how it processed each line was being slow. The actual
"_reannotate" code which goes and does a diff barely showed up.
So this code just switches around 2 things:
1) reannotate() and _reannotate() work on lists rather than being
generator functions. Under lsprof this was quite a bit faster, though
that might just be lsprof overhead.
2) Special case when there are only 2 parents. You can do simple == and
!= comparisons without having to create a set for each line, etc. It
also allows us to share the tuples
According to '--lsprof' this dropped the time spent directly in
reannotate from 8s down to 1s. And manual 'time bzr annotate --show-ids'
dropped from 13s to 8s.
The tests still pass, and the logic is pretty much the same, just
spelled out, rather than using a set() to do the logic. Going by lsprof,
the big expense was certainly the last loop, I don't know if it was the
zip() or all of the if checks.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
More information about the bazaar