Skip to content

Commit 3cee78e

Browse files
committed
Added endurance run to check all objects in the git source repository, something like a primtive git-fsck, which indeed takes a while to run. Its useful to see the memory consumption, which must stay static in the domain of physical memory
1 parent 4503a78 commit 3cee78e

2 files changed

Lines changed: 28 additions & 4 deletions

File tree

db/pack.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,15 @@ def update_pack_entity_cache(self, force=False):
157157
# reinitialize prioritiess
158158
self._sort_entities()
159159
return True
160+
161+
def entities(self):
162+
""":return: list of pack entities operated upon by this database"""
163+
return [ item[1] for item in self._entities ]
160164

161165
def sha_iter(self):
162166
"""Return iterator yielding 20 byte shas for the packed objects in this data base"""
163167
sha_list = list()
164-
for entity in (item[1] for item in self._entities):
168+
for entity in self.entities():
165169
index = entity.index()
166170
sha_by_index = index.sha
167171
for index in xrange(index.size()):
Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from time import time
1111
import random
1212

13-
class TestGitDBPerformance(TestBigRepoR):
13+
class TestPackedDBPerformance(TestBigRepoR):
1414

1515
def test_pack_random_access(self):
1616
pdb = PackedDB(os.path.join(self.gitrepopath, "objects/pack"))
@@ -22,7 +22,6 @@ def test_pack_random_access(self):
2222
ns = len(sha_list)
2323
print >> sys.stderr, "PDB: looked up %i shas by index in %f s ( %f shas/s )" % (ns, elapsed, ns / elapsed)
2424

25-
2625
# sha lookup: best-case and worst case access
2726
pdb_pack_info = pdb._pack_info
2827
access_times = list()
@@ -39,7 +38,7 @@ def test_pack_random_access(self):
3938

4039
# discard cache
4140
del(pdb._entities)
42-
pdb._entities
41+
pdb.entities()
4342
print >> sys.stderr, "PDB: looked up %i sha (random=%i) in %f s ( %f shas/s )" % (ns, rand, elapsed, ns / elapsed)
4443
# END for each random mode
4544
elapsed_order, elapsed_rand = access_times
@@ -72,3 +71,24 @@ def test_pack_random_access(self):
7271
total_kib = total_size / 1000
7372
print >> sys.stderr, "PDB: Obtained %i streams by sha and read all bytes totallying %i KiB ( %f KiB / s ) in %f s ( %f streams/s )" % (max_items, total_kib, total_kib/elapsed , elapsed, max_items / elapsed)
7473

74+
75+
print >> sys.stderr, "Endurance run: verify streaming of %i objects (crc and sha)" % ns
76+
for crc in range(2):
77+
count = 0
78+
st = time()
79+
for entity in pdb.entities():
80+
pack_verify = entity.is_valid_stream
81+
sha_by_index = entity.index().sha
82+
for index in xrange(entity.index().size()):
83+
try:
84+
assert pack_verify(sha_by_index(index), use_crc=crc)
85+
except UnsupportedOperation:
86+
pass
87+
# END ignore old indices
88+
count += 1
89+
# END for each index
90+
# END for each entity
91+
elapsed = time() - st
92+
print >> sys.stderr, "PDB: verified %i objects (crc=%i) in %f s ( %f objects/s )" % (count, crc, elapsed, count / elapsed)
93+
# END for each verify mode
94+

0 commit comments

Comments
 (0)