[MERGE] Single lock for 'bzr diff'

John Arbash Meinel john at arbash-meinel.com
Thu Sep 27 18:07:22 BST 2007


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

At the moment, when running 'bzr diff' (no arguments) we end up grabbing (and
releasing) far too many read locks. The reason is that 'diff_cmd_helper()'
doesn't actually lock the tree, and we haven't locked it before we entered.

Which means we actually have to re-lock the tree for each operation
(basis_tree(), which actually locks it 2 times for get_parent_ids() and for
revision_tree()) etc.

Also, because of how the timing works, we also end up with 2 different read
locks on the DirState object. I don't know how exactly this happened, but it
means that 'bzr diff' won't update the cached stat values (because it fails to
upgrade to a write lock).

The attached patch fixes a lot of this by simply adding a
tree.lock_read()/unlock() call around diff_cmd_helper. There are other ways it
could be done (have diff_cmd_helper lock the tree, and call out to
_diff_cmd_helper, etc).

This seemed easy and expedient.

I don't have a specific test for it...

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

iD8DBQFG++NKJdeBCYSNAAMRAjojAKC5OePpws0yGN6wxMBvV/1OSdD6igCgi8Qp
LeTqnaSUYhExRmYoA6Jj6FU=
=rPzH
-----END PGP SIGNATURE-----
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: single_lock_for_diff.patch
Url: https://lists.ubuntu.com/archives/bazaar/attachments/20070927/36b1505f/attachment.diff 


More information about the bazaar mailing list