~jameinel/loggerhead/known_graph

« back to all changes in this revision

Viewing changes to loggerhead/wholehistory.py

  • Committer: John Arbash Meinel
  • Date: 2010-03-29 18:35:19 UTC
  • Revision ID: john@arbash-meinel.com-20100329183519-5hrr0sz0q3kopsyx
Some timing and memory perf from using StaticTuple.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
import logging
22
22
import time
23
23
 
 
24
#from bzrlib import static_tuple, trace
24
25
from bzrlib.revision import is_null, NULL_REVISION
25
26
 
26
27
 
44
45
    See History.__doc__ for what these data structures mean.
45
46
    """
46
47
    z = time.time()
 
48
    #trace.debug_memory('before computing')
47
49
 
48
50
    last_revid = branch.last_revision()
49
51
 
73
75
    #log.info('built revision graph cache: %r secs' % (time.time() - z,))
74
76
    print 'built revision graph cache: %.3fs' % (time.time() - z,)
75
77
 
 
78
    #trace.debug_memory('after computing')
76
79
    return (rev_info, rev_indices)
77
80
 
78
81
 
94
97
 
95
98
    get_parent_keys = graph.get_parent_keys
96
99
    get_child_keys = graph.get_child_keys
 
100
    # Using StaticTuple does show a memory reduction. There doesn't seem to be
 
101
    # a time-difference wrt how long it takes to build (probably because we
 
102
    # have gc disabled?). StaticTuple helps more when things have long
 
103
    # lifetimes, as it prevents gc from degrading as much.
 
104
    # Anyway, peak memory was 81.1MB down from 85.6MB. Not a huge difference,
 
105
    # but something. Note that StaticTuple won't work directly because the
 
106
    # caching code uses 'marshal' which requires native python objects like
 
107
    # 'tuple' and doesn't support StaticTuple.
 
108
    # stuple = static_tuple.StaticTuple.from_sequence
 
109
    # st = static_tuple.StaticTuple
97
110
    for seq, info in enumerate(merge_sorted):
98
111
        #seq, revid, merge_depth, revno, end_of_merge = info
99
112
        # Switch back from a tuple key to a simple string rev_id
100
113
        rev_id = info.key[-1]
101
114
        revno_str = '.'.join(map(str, info.revno))
102
 
        parent_ids = [p[-1] for p in get_parent_keys(info.key)]
 
115
        parent_ids = tuple([p[-1] for p in get_parent_keys(info.key)])
103
116
        rev_indices[rev_id] = len(rev_info)
104
117
        # TODO: StaticTuple / just use the original merge_sorted object
105
118
        basic_info = (seq, rev_id, info.merge_depth, revno_str,
112
125
            child_ids = ()
113
126
        # TODO: StaticTuple
114
127
        rev_info.append((basic_info, child_ids, parent_ids))
 
128
    # 
115
129
    return rev_info, rev_indices