~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repofmt/groupcompress_repo.py

  • Committer: John Arbash Meinel
  • Date: 2010-05-11 10:45:26 UTC
  • mto: This revision was merged to the branch mainline in revision 5225.
  • Revision ID: john@arbash-meinel.com-20100511104526-zxnstcxta22hzw2n
Implement a compiled extension for parsing the text key out of a CHKInventory value.

Related to bug #562666. This seems to shave 5-10% out of the time spent doing a complete
branch of bzr.dev/launchpad/etc.

Show diffs side-by-side

added added

removed removed

Lines of Context:
262
262
        remaining_keys = set(keys)
263
263
        counter = [0]
264
264
        if self._gather_text_refs:
265
 
            bytes_to_info = inventory.CHKInventory._bytes_to_utf8name_key
266
265
            self._text_refs = set()
267
266
        def _get_referenced_stream(root_keys, parse_leaf_nodes=False):
268
267
            cur_keys = root_keys
289
288
                    # Store is None, because we know we have a LeafNode, and we
290
289
                    # just want its entries
291
290
                    for file_id, bytes in node.iteritems(None):
292
 
                        name_utf8, file_id, revision_id = bytes_to_info(bytes)
293
 
                        self._text_refs.add((file_id, revision_id))
 
291
                        self._text_refs.add(chk_map._bytes_to_text_key(bytes))
294
292
                def next_stream():
295
293
                    stream = source_vf.get_record_stream(cur_keys,
296
294
                                                         'as-requested', True)
647
645
        chk_diff = chk_map.iter_interesting_nodes(
648
646
            chk_bytes_no_fallbacks, root_key_info.interesting_root_keys,
649
647
            root_key_info.uninteresting_root_keys)
650
 
        bytes_to_info = inventory.CHKInventory._bytes_to_utf8name_key
651
648
        text_keys = set()
652
649
        try:
653
 
            for record in _filter_text_keys(chk_diff, text_keys, bytes_to_info):
 
650
            for record in _filter_text_keys(chk_diff, text_keys,
 
651
                                            chk_map._bytes_to_text_key):
654
652
                pass
655
653
        except errors.NoSuchRevision, e:
656
654
            # XXX: It would be nice if we could give a more precise error here.
1087
1085
                uninteresting_root_keys.add(inv.id_to_entry.key())
1088
1086
                uninteresting_pid_root_keys.add(
1089
1087
                    inv.parent_id_basename_to_file_id.key())
1090
 
        bytes_to_info = inventory.CHKInventory._bytes_to_utf8name_key
1091
1088
        chk_bytes = self.from_repository.chk_bytes
1092
1089
        def _filter_id_to_entry():
1093
1090
            interesting_nodes = chk_map.iter_interesting_nodes(chk_bytes,
1094
1091
                        self._chk_id_roots, uninteresting_root_keys)
1095
1092
            for record in _filter_text_keys(interesting_nodes, self._text_keys,
1096
 
                    bytes_to_info):
 
1093
                    chk_map._bytes_to_text_key):
1097
1094
                if record is not None:
1098
1095
                    yield record
1099
1096
            # Consumed
1187
1184
    return result
1188
1185
 
1189
1186
 
1190
 
def _filter_text_keys(interesting_nodes_iterable, text_keys, bytes_to_info):
 
1187
def _filter_text_keys(interesting_nodes_iterable, text_keys, bytes_to_text_key):
1191
1188
    """Iterate the result of iter_interesting_nodes, yielding the records
1192
1189
    and adding to text_keys.
1193
1190
    """
 
1191
    text_keys_update = text_keys.update
1194
1192
    for record, items in interesting_nodes_iterable:
1195
 
        for name, bytes in items:
1196
 
            # Note: we don't care about name_utf8, because groupcompress repos
1197
 
            # are always rich-root, so there are no synthesised root records to
1198
 
            # ignore.
1199
 
            _, file_id, revision_id = bytes_to_info(bytes)
1200
 
            file_id = intern(file_id)
1201
 
            revision_id = intern(revision_id)
1202
 
            text_keys.add(StaticTuple(file_id, revision_id).intern())
 
1193
        text_keys_update([bytes_to_text_key(b) for n,b in items])
1203
1194
        yield record
1204
1195
 
1205
1196