OS locks woes

John Arbash Meinel john at arbash-meinel.com
Fri Jun 19 14:46:45 BST 2009


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

Martin Pool wrote:
> 2009/6/19 Alexander Belchenko <bialix at ukr.net>:
>> Using this patch from Martin (gzlist) and some small change to the code to
>> print filename of OS-locked file (I've did it for testing unicode locking)
>> and I found that dirstate locked toooo often in some situations.
>>
>> May be our dear bzr.devs already know this, but -Dlock does not show this
>> kind of info, so I show you my results. As you could see many operations
>> lock the dirstate 3-4 and more times. I don't think it's right, especially
>> regarding to various OS locks problem on Windows.
> 
> I think you're right, that is bad.  -Dlock should report on them, and
> we should perhaps add some assertions it does not happen too many
> times.
> 
> 
> 

So, as I've mentioned multiple times the root cause of this is that
"tree.basis_tree()" is returning an object that maintains its own
connection to the DirState file and its own lifetime of locks.

Well, it isn't meant to, but it gets handed a DirState object, and the
WT itself will release that and grab another depending on its lock state.

When I tried to change the code to not use the result of "basis_tree()"
outside of the lifetime of the containing tree, it was rather difficult
to do so.

One option (especially with CHK formats) is to stop returning a
DirStateRevisionTree at all. We used it because it was faster to parse
the DirState inventory, but any more that isn't always true.

"iter_changes()" is already tuned so that if you do:

basis_rev = wt.last_revision()
basis_tree = wt.branch.repository.revision_tree(basis_rev)

wt.iter_changes(basis_tree)

It will use the optimized path.
  # the source must be a revtree or dirstate rev tree.
  if not isinstance(source,
      (revisiontree.RevisionTree, DirStateRevisionTree)):
      return False

^- Allows for generic RevisionTrees
v- As long as the revision id is in the dirstate file

  # the source revid must be in the target dirstate
  if not (source._revision_id == NULL_REVISION or
      source._revision_id in target.get_parent_ids()):
      # TODO: what about ghosts? it may well need to
      # check for them explicitly.
      return False
  return True


Something to think about, at least.

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

iEYEARECAAYFAko7lsUACgkQJdeBCYSNAANi0QCgzyOwBBmciagazjVuhYg368BM
FoMAoIrSp5ZMLWAT/e2uc5qJRtiz/ukL
=SPUT
-----END PGP SIGNATURE-----



More information about the bazaar mailing list