[MERGE] Reading pack-names triggers 3 reads

John Arbash Meinel john at arbash-meinel.com
Sun Nov 9 22:27:35 GMT 2008


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

John Arbash Meinel wrote:
> While I was at it, I also found that 'BTree.iter_all_entries()' on the
> pack-names file, causes it to be read 3 times.
> 
> 1) iter_all_entries() calls '.key_count()' which reads the root node
> 2) It then proceeds to call _read_nodes() for all "needed" nodes, but
> this includes the root node.
> 3) _read_nodes() when it doesn't know the size of the index, would
> trigger a read of the index, just to get its size, and then throw away
> the bytes, just to read it again in the next call.
> 
> This patch adds both fixes, and finally drops the number of reads of
> "pack-names" to 1 as it should be.
> 

Here is a more appropriate fix which just changes reading pack-names
from 3 times down to one. It includes tests, etc. This path really only
happens for 'pack-names' because it is the only file that we don't know
the size ahead of time.

There was also a subtle bug in the code if pack-names ever became larger
than a single page (which is really unlikely, but theoretically possible).

John
=:->

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

iEYEARECAAYFAkkXY9YACgkQJdeBCYSNAAOySQCeNfcJA4CCmNPT5/D6ni7GHuXO
72kAn2oFNowJLWTmkD45DjD9DhUSbBNq
=Ldmg
-----END PGP SIGNATURE-----
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: btree_no_size.patch
Url: https://lists.ubuntu.com/archives/bazaar/attachments/20081109/7d0e331c/attachment.diff 


More information about the bazaar mailing list