PATCH: cache basis inventory in .bzr

John A Meinel john at arbash-meinel.com
Mon Dec 19 20:10:56 GMT 2005


Aaron Bentley wrote:
> John A Meinel wrote:
>>> Should get_basis always succeed, even if it isn't cached? That seems
>>> generally useful to me.
>>> Also, I wish there was some way to mark that the basis-inventory needed
>>> to be updated. get_basis_inventory() shouldn't be deleting or modifying
>>> the file (it is a readonly operation, and has to be, because it will be
>>> called from other readonly operations).
> 
> I'm not sure what do do about that.  It may be that get_basis_inventory
> is *logically* read_only, but that we actually do write it atomically.
> 
> If the basis we want isn't there, we read the branch data, write the
> basis (if we can), and return the branch data.
> 
>>> For now, it should be updated after something happens which modifies it
>>> (pull/commit).
> 
> We could have a WorkingTree.set_basis() function which would update it.

Well, we would always have some sort of function which would update the
basis-inventory. It should require a write lock.
The question is that if you are reading, someone might have done
something which causes the basis inventory to be out of sync. (Say,
using a different version of bzr, which doesn't know about the current
method).

It would be nice to clean things up if we found we are out of date.
I suppose it depends if we feel that a read-only function can modify the
cache. I think we have readonly functions which modify stat-cache, so it
would be reasonable to consider basis-inventory to be a cache, and it
can be modified by a readonly operation.

> 
>>> The other nice thing would be to read just the first line, and make sure
>>> it was the right version, before going through the effort of actually
>>> parsing the inventory.
>>> I can think of a regex that should do a decent job.
>>> Is it worth implementing, or is it just a hackish workaround?
> 
> Seems on the hackish end, but if it makes a significant difference,
> maybe it's worth it.  When I proposed storing the inventory-id in the
> file, I was thinking of storing it in plaintext on the first line, then
> starting the XML after that, which is also hackish.

Yeah, though it is nice in that you call readline(), and you don't have
to seek. :)
It only makes a significant difference when the basis-inventory is out
of date. So it depends how often that happens. In a nice world, it is
never, and it isn't worth the hack. I'm thinking it will be infrequent,
and if we update the basis-inventory if it is out of date, the frequency
also drops.

Probably I will delay on adding the pre-check, and if people agree, just
consider basis-inventory a working tree cache file, which can be
atomically modified by a readonly lock.

John
=:->

> 
> Aaron

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 249 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20051219/7d00b242/attachment.pgp 


More information about the bazaar mailing list