Rev 4722: Using StaticTuple.intern() and recursive structures. in http://bazaar.launchpad.net/~jameinel/bzr/2.1-static-tuple

John Arbash Meinel john at arbash-meinel.com
Wed Sep 30 19:52:07 BST 2009


At http://bazaar.launchpad.net/~jameinel/bzr/2.1-static-tuple

------------------------------------------------------------
revno: 4722
revision-id: john at arbash-meinel.com-20090930185201-gjsozmi8khwf21uh
parent: john at arbash-meinel.com-20090930183754-p8h2fy6nshpedh8i
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.1-static-tuple
timestamp: Wed 2009-09-30 13:52:01 -0500
message:
  Using StaticTuple.intern() and recursive structures.
  
  Brings peak bzr.dev memory down to: 102920KB, still with a 6.0MB intern dict.
  This is down from 121052KB with bzr.dev and roughly 107380KB with the Key version.
  The big win is that all of the btree data structures can be StaticTuple
  because we know we are just referencing either strings or tuples of strings,
  or tuples of mixed tuples and strings, but still all very static data.
-------------- next part --------------
=== modified file 'bzrlib/_btree_serializer_pyx.pyx'
--- a/bzrlib/_btree_serializer_pyx.pyx	2009-09-30 18:00:42 +0000
+++ b/bzrlib/_btree_serializer_pyx.pyx	2009-09-30 18:52:01 +0000
@@ -102,7 +102,9 @@
     Py_DECREF_ptr(py_str)
     return result
 
-# from bzrlib import _keys_type_c
+from bzrlib import _static_tuple_c
+cdef object StaticTuple
+StaticTuple = _static_tuple_c.StaticTuple
 
 
 cdef class BTreeLeafParser:
@@ -179,7 +181,7 @@
             # PyTuple_SET_ITEM(key, loop_counter, key_element)
             PyTuple_SET_ITEM(key, loop_counter, key_element)
         # return _keys_type_c.Key(*key)
-        return key
+        return StaticTuple(*key).intern()
 
     cdef int process_line(self) except -1:
         """Process a line in the bytes."""
@@ -263,12 +265,12 @@
                         # key runs to the end
                         temp_ptr = ref_ptr
                     PyList_Append(ref_list, self.extract_key(temp_ptr))
-                ref_list = tuple(ref_list)
+                ref_list = StaticTuple(*ref_list).intern()
                 PyList_Append(ref_lists, ref_list)
                 # prepare for the next reference list
                 self._start = next_start
-            ref_lists = tuple(ref_lists)
-            node_value = (value, ref_lists)
+            ref_lists = StaticTuple(*ref_lists)
+            node_value = StaticTuple(value, ref_lists)
         else:
             if last != self._start:
                 # unexpected reference data present



More information about the bazaar-commits mailing list