[MERGE] Accelerate loom up-thread/down-thread operations

John Arbash Meinel john at arbash-meinel.com
Wed Mar 5 08:10:33 GMT 2008


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

Aaron Bentley wrote:
> Hi all,
> 
> This patch accelerates Bazaar's loom support on packs.
> 
> Looms use BzrBranch6.generate_revision_history, which is currently
> slower than necessary.  It generates the lefthand history twice-- the
> new implementation of generate_revision_history fixes that.
> 
> But generating the lefthand history uses get_revision_graph, which John
> has already determined is inefficient.  The changes to _lefthand_history
> use Graph instead, which is much more efficient.  As a side effect, it
> may also accelerate other operations that use revision_history on
> Branch6 branches.
> 
> Apparently, we missed BzrBranch.set_revision_info in our None =>
> NULL_REVISION migration.  This pushes the None => NULL_REVISION
> conversion out into the BzrBranch.set_revision_info methods, to simplify
> the core functions.
> 
> down-thread TIMINGS (best of 3):
> OLD:
> real    0m15.824s
> user    0m12.545s
> sys     0m0.316s
> 
> NEW:
> real    0m3.524s
> user    0m2.596s
> sys     0m0.212s
> 
> This is ~ 4.5x faster.
> 
> It's also worth noting that the loom format really needs an upgrade so
> that it can use set_revision_info rather than generate_revision_history.
> 
> Aaron

=== modified file 'bzrlib/branch.py'
- --- bzrlib/branch.py	2008-02-24 16:42:13 +0000
+++ bzrlib/branch.py	2008-03-04 23:13:31 +0000
@@ -1413,6 +1413,8 @@
         configured to check constraints on history, in which case this
may not
         be permitted.
         """
+        if revision_id is None:
+            revision_id = _mod_revision.NULL_REVISION

^- Shouldn't that be "revision_id = ensure_null(revision_id)" ?

v- Same thing here

     @needs_write_lock
     def set_last_revision_info(self, revno, revision_id):
+        if revision_id is None:
+            revision_id = _mod_revision.NULL_REVISION
         if self._get_append_revisions_only():
             self._check_history_violation(revision_id)
         self._write_last_revision_info(revno, revision_id)




- -        if revision_id is None:
- -            revision_id = 'null:'
         out_string = '%d %s\n' % (revno, revision_id)
         self.control_files.put_bytes('last-revision', out_string)

^- And this should probably at least become:
assert revision_id is not None, 'You should be using NULL_REVISION
instead of None'

Though it wouldn't be very nice for users to get an assert here, but it
is better than getting a weird traceback because the None won't serialize.

BB:tweak

John
=:->



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

iD8DBQFHzlU9JdeBCYSNAAMRApZ7AJ9xIMFGjqkaQNQCgoDI+e5UVJMHawCfdGf9
DVHkC1x/L3ohLnDxvc33BhI=
=kCbn
-----END PGP SIGNATURE-----



More information about the bazaar mailing list