Rev 4760: interning key values in the CHKInventory.deserialize() in http://bazaar.launchpad.net/~jameinel/bzr/2.1-chk-inv

John Arbash Meinel john at arbash-meinel.com
Tue Oct 20 21:29:06 BST 2009


At http://bazaar.launchpad.net/~jameinel/bzr/2.1-chk-inv

------------------------------------------------------------
revno: 4760
revision-id: john at arbash-meinel.com-20091020202852-pwn5id90gm3kmap3
parent: pqm at pqm.ubuntu.com-20091020114259-xxou482wvh20lhl6
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.1-chk-inv
timestamp: Tue 2009-10-20 15:28:52 -0500
message:
  interning key values in the CHKInventory.deserialize()
  
  This saves 190MB => 180MB.
-------------- next part --------------
=== modified file 'bzrlib/chk_map.py'
--- a/bzrlib/chk_map.py	2009-10-08 04:35:01 +0000
+++ b/bzrlib/chk_map.py	2009-10-20 20:28:52 +0000
@@ -83,6 +83,8 @@
 class CHKMap(object):
     """A persistent map from string to string backed by a CHK store."""
 
+    __slots__ = ('_store', '_root_node', '_search_key_func')
+
     def __init__(self, store, root_key, search_key_func=None):
         """Create a CHKMap object.
 
@@ -556,6 +558,10 @@
         adding the header bytes, and without prefix compression.
     """
 
+    __slots__ = ('_key', '_len', '_maximum_size', '_key_width',
+                 '_raw_size', '_items', '_search_prefix', '_search_key_func'
+                )
+
     def __init__(self, key_width=1):
         """Create a node.
 
@@ -650,6 +656,8 @@
         the key/value pairs.
     """
 
+    __slots__ = ('_common_serialised_prefix', '_serialise_key')
+
     def __init__(self, search_key_func=None):
         Node.__init__(self)
         # All of the keys in this leaf node share this common prefix
@@ -947,6 +955,8 @@
         LeafNode or InternalNode.
     """
 
+    __slots__ = ('_node_width',)
+
     def __init__(self, prefix='', search_key_func=None):
         Node.__init__(self)
         # The size of an internalnode with default values and no children.

=== modified file 'bzrlib/inventory.py'
--- a/bzrlib/inventory.py	2009-10-14 13:47:28 +0000
+++ b/bzrlib/inventory.py	2009-10-20 20:28:52 +0000
@@ -1918,11 +1918,11 @@
                 raise errors.BzrError('Duplicate key in inventory: %r\n%r'
                                       % (key, bytes))
             info[key] = value
-        revision_id = info['revision_id']
-        root_id = info['root_id']
-        search_key_name = info.get('search_key_name', 'plain')
-        parent_id_basename_to_file_id = info.get(
-            'parent_id_basename_to_file_id', None)
+        revision_id = intern(info['revision_id'])
+        root_id = intern(info['root_id'])
+        search_key_name = intern(info.get('search_key_name', 'plain'))
+        parent_id_basename_to_file_id = intern(info.get(
+            'parent_id_basename_to_file_id', None))
         id_to_entry = info['id_to_entry']
 
         result = CHKInventory(search_key_name)



More information about the bazaar-commits mailing list