Mercurial > hg
comparison tests/test-parseindex2.py @ 16363:2cdd7e63211b
parsers: incrementally parse the revlog index in C
We only parse entries in a revlog index file when they are actually
needed, and cache them when first requested.
This makes a huge difference to performance on large revlogs when
accessing the tip revision or performing a handful of numeric lookups
(very common cases). For instance, "hg --time tip --template {node}"
on a tree with 300,000 revs takes 0.15 before, 0.02 after.
Even for revlog-intensive operations (e.g. running "hg log" to
completion), the lazy approach is about 1% faster than the eager
parse_index2.
author | Bryan O'Sullivan <bryano@fb.com> |
---|---|
date | Thu, 05 Apr 2012 13:00:35 -0700 |
parents | 5ef5eb1f3515 |
children | e8d37b78acfb |
comparison
equal
deleted
inserted
replaced
16361:6097ede2be4d | 16363:2cdd7e63211b |
---|---|
50 # add the magic null revision at -1 | 50 # add the magic null revision at -1 |
51 index.append((0, 0, 0, -1, -1, -1, -1, nullid)) | 51 index.append((0, 0, 0, -1, -1, -1, -1, nullid)) |
52 | 52 |
53 return index, cache | 53 return index, cache |
54 | 54 |
55 | |
56 data_inlined = '\x00\x01\x00\x01\x00\x00\x00\x00\x00\x00\x01\x8c' \ | 55 data_inlined = '\x00\x01\x00\x01\x00\x00\x00\x00\x00\x00\x01\x8c' \ |
57 '\x00\x00\x04\x07\x00\x00\x00\x00\x00\x00\x15\x15\xff\xff\xff' \ | 56 '\x00\x00\x04\x07\x00\x00\x00\x00\x00\x00\x15\x15\xff\xff\xff' \ |
58 '\xff\xff\xff\xff\xff\xebG\x97\xb7\x1fB\x04\xcf\x13V\x81\tw\x1b' \ | 57 '\xff\xff\xff\xff\xff\xebG\x97\xb7\x1fB\x04\xcf\x13V\x81\tw\x1b' \ |
59 'w\xdduR\xda\xc6\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' \ | 58 'w\xdduR\xda\xc6\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' \ |
60 'x\x9c\x9d\x93?O\xc30\x10\xc5\xf7|\x8a\xdb\x9a\xa8m\x06\xd8*\x95' \ | 59 'x\x9c\x9d\x93?O\xc30\x10\xc5\xf7|\x8a\xdb\x9a\xa8m\x06\xd8*\x95' \ |
92 '\x13\x00\x00\x00\x00\x01\xec\x00\x00\x03\x06\x00\x00\x00\x01' \ | 91 '\x13\x00\x00\x00\x00\x01\xec\x00\x00\x03\x06\x00\x00\x00\x01' \ |
93 '\x00\x00\x00\x03\x00\x00\x00\x02\xff\xff\xff\xff\x12\xcb\xeby1' \ | 92 '\x00\x00\x00\x03\x00\x00\x00\x02\xff\xff\xff\xff\x12\xcb\xeby1' \ |
94 '\xb6\r\x98B\xcb\x07\xbd`\x8f\x92\xd9\xc4\x84\xbdK\x00\x00\x00' \ | 93 '\xb6\r\x98B\xcb\x07\xbd`\x8f\x92\xd9\xc4\x84\xbdK\x00\x00\x00' \ |
95 '\x00\x00\x00\x00\x00\x00\x00\x00\x00' | 94 '\x00\x00\x00\x00\x00\x00\x00\x00\x00' |
96 | 95 |
96 def parse_index2(data, inline): | |
97 index, chunkcache = parsers.parse_index2(data, inline) | |
98 return list(index), chunkcache | |
99 | |
97 def runtest() : | 100 def runtest() : |
98 | |
99 py_res_1 = py_parseindex(data_inlined, True) | 101 py_res_1 = py_parseindex(data_inlined, True) |
100 c_res_1 = parsers.parse_index2(data_inlined, True) | 102 c_res_1 = parse_index2(data_inlined, True) |
101 | 103 |
102 py_res_2 = py_parseindex(data_non_inlined, False) | 104 py_res_2 = py_parseindex(data_non_inlined, False) |
103 c_res_2 = parsers.parse_index2(data_non_inlined, False) | 105 c_res_2 = parse_index2(data_non_inlined, False) |
104 | 106 |
105 if py_res_1 != c_res_1: | 107 if py_res_1 != c_res_1: |
106 print "Parse index result (with inlined data) differs!" | 108 print "Parse index result (with inlined data) differs!" |
107 | 109 |
108 if py_res_2 != c_res_2: | 110 if py_res_2 != c_res_2: |