Rev 22: Add random_reload test that reopens the indices. Shows cold-start performance well. in http://people.ubuntu.com/~robertc/baz2.0/plugins/index2/trunk

Robert Collins robertc at robertcollins.net
Thu Jul 3 09:28:55 BST 2008


At http://people.ubuntu.com/~robertc/baz2.0/plugins/index2/trunk

------------------------------------------------------------
revno: 22
revision-id: robertc at robertcollins.net-20080703082855-5smrfzrb8gamkfbh
parent: robertc at robertcollins.net-20080703073137-c2201o4l8zhne7b2
committer: Robert Collins <robertc at robertcollins.net>
branch nick: trunk
timestamp: Thu 2008-07-03 18:28:55 +1000
message:
  Add random_reload test that reopens the indices. Shows cold-start performance well.
modified:
  indexbench.py                  indexbench.py-20080702083855-5tju02y79rw7kkzh-1
=== modified file 'indexbench.py'
--- a/indexbench.py	2008-07-03 03:45:49 +0000
+++ b/indexbench.py	2008-07-03 08:28:55 +0000
@@ -117,8 +117,17 @@
         finish = time.time()
         print "%s: iter_all_entries in %0.3f" % (label, finish - now)
 # random shuffle, all keys (name_keys comes preshuffled)
+# This tests random access across the index - which on GraphIndex will exhaust
+# VM, on BTreeIndex can cache-thrash.
     if 'shuffle' in fixtures:
-        run(label, 'iter_random_one', iter_random_one, label, drop_cache, names, target, factory, name_keys)
+        run(label, 'iter_random_one', iter_random_one, label, 'iter_random_one',
+            drop_cache, names, target, factory, name_keys, False)
+# random shuffle, all keys (name_keys comes preshuffled), reopening the index
+# each time. This tests the minimum time to get to an average key from 'start'.
+# On GraphIndex this should be much slower than on BTree index.
+    if 'random_reload' in fixtures:
+        run(label, 'iter_random_reload', iter_random_one, 'iter_random_reload',
+            label, drop_cache, names, target, factory, name_keys, True)
 # text extraction simulation (follow a compression graph) for text_keys
     if 'text' in fixtures:
         text_names = [name for name in names if name.endswith('.tix')]
@@ -165,7 +174,8 @@
     print "%s: -------Done---------" % (label,)
 
 
-def iter_random_one(label, drop_cache, names, target, factory, name_keys):
+def iter_random_one(label, fixture_label, drop_cache, names, target, factory,
+    name_keys, reload_index):
     drop_cache()
     reset_hit_counts()
     now = time.time()
@@ -174,8 +184,11 @@
         shuffle(order)
         for key in order:
             index.iter_entries([key]).next()
+            if reload_index:
+                index = factory(index._transport, index._name, index._size)
+                drop_cache()
     finish = time.time()
-    print "%s: iter_random_one in %0.3f,%s" % (label, finish - now, hits())
+    print "%s: %s in %0.3f,%s" % (label, fixture_label, finish - now, hits())
 
 
 def revision_search(label, drop_cache, names, target, factory, tip_revision_id):
@@ -221,7 +234,8 @@
         Option('btree', help='bench the BTreeGraphIndex class'),
         Option('drop-cache', help='drop caches between fixtures'),
         ListOption('fixture', type=str,
-            help='fixtures to test: one of all, shuffle, text, revision, miss'),
+            help='fixtures to test: one of all, shuffle, text, revision, miss, '
+            'random_reload.'),
         # lspro because --lsprof is a global option, and they interfere with each other.
         Option('lspro', help='generate class.fixture.callgrind lsprof files'),
         Option('calltree', help='generate KCachegrind calltrees when profiling.'),
@@ -233,7 +247,7 @@
     def run(self, sample_branch, graph=True, btree=True, drop_cache=False,
             fixture=None, lspro=False, calltree=True):
         if not fixture:
-            fixture = ['all', 'shuffle', 'text', 'revision', 'miss']
+            fixture = ['all', 'shuffle', 'text', 'revision', 'miss', 'random_reload']
         global use_calltree
         use_calltree = calltree
         from bzrlib.branch import Branch




More information about the bazaar-commits mailing list