Rev 4209: (jam) Use a FIFOCache for the btree internal node cache. in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Fri Mar 27 05:14:53 GMT 2009


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 4209
revision-id: pqm at pqm.ubuntu.com-20090327051450-t7pdaegr0h6f40ul
parent: pqm at pqm.ubuntu.com-20090326131816-4nzmlssnd4huc5cu
parent: john at arbash-meinel.com-20090327042335-5a8ii0h5sa4ktx04
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2009-03-27 05:14:50 +0000
message:
  (jam) Use a FIFOCache for the btree internal node cache.
modified:
  bzrlib/btree_index.py          index.py-20080624222253-p0x5f92uyh5hw734-7
    ------------------------------------------------------------
    revno: 4208.1.2
    revision-id: john at arbash-meinel.com-20090327042335-5a8ii0h5sa4ktx04
    parent: john at arbash-meinel.com-20090326205221-ddrlzj00y65k5t0w
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: jam-integration
    timestamp: Thu 2009-03-26 23:23:35 -0500
    message:
      Switch to using a FIFOCache.
      
      That gives us the lookup performance of a dict, while still being capped
      at max size.
    modified:
      bzrlib/btree_index.py          index.py-20080624222253-p0x5f92uyh5hw734-7
    ------------------------------------------------------------
    revno: 4208.1.1
    revision-id: john at arbash-meinel.com-20090326205221-ddrlzj00y65k5t0w
    parent: pqm at pqm.ubuntu.com-20090326131816-4nzmlssnd4huc5cu
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: jam-integration
    timestamp: Thu 2009-03-26 15:52:21 -0500
    message:
      Use a simple dict cache for btree internal_node lookups.
    modified:
      bzrlib/btree_index.py          index.py-20080624222253-p0x5f92uyh5hw734-7
=== modified file 'bzrlib/btree_index.py'
--- a/bzrlib/btree_index.py	2009-03-24 01:53:42 +0000
+++ b/bzrlib/btree_index.py	2009-03-27 04:23:35 +0000
@@ -30,6 +30,7 @@
     chunk_writer,
     debug,
     errors,
+    fifo_cache,
     index,
     lru_cache,
     osutils,
@@ -641,7 +642,11 @@
         # Default max size is 100,000 leave values
         self._leaf_value_cache = None # lru_cache.LRUCache(100*1000)
         self._leaf_node_cache = lru_cache.LRUCache(_NODE_CACHE_SIZE)
-        self._internal_node_cache = lru_cache.LRUCache()
+        # We could limit this, but even a 300k record btree has only 3k leaf
+        # nodes, and only 20 internal nodes. So the default of 100 nodes in an
+        # LRU would mean we always cache everything anyway, no need to pay the
+        # overhead of LRU
+        self._internal_node_cache = fifo_cache.FIFOCache(100)
         self._key_count = None
         self._row_lengths = None
         self._row_offsets = None # Start of each row, [-1] is the end




More information about the bazaar-commits mailing list