Rev 4682: Caching the specific_fileids => expanded form brings us to 0m51s. in http://bazaar.launchpad.net/~jameinel/bzr/2.0.1-faster-get-deltas-bug374730
John Arbash Meinel
john at arbash-meinel.com
Thu Sep 24 23:11:03 BST 2009
At http://bazaar.launchpad.net/~jameinel/bzr/2.0.1-faster-get-deltas-bug374730
------------------------------------------------------------
revno: 4682
revision-id: john at arbash-meinel.com-20090924221050-t6n0cd92ry2s39mp
parent: john at arbash-meinel.com-20090924220102-r0wjsrf47i1y7cpw
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.0.1-faster-get-deltas-bug374730
timestamp: Thu 2009-09-24 17:10:50 -0500
message:
Caching the specific_fileids => expanded form brings us to 0m51s.
-------------- next part --------------
=== modified file 'bzrlib/repofmt/groupcompress_repo.py'
--- a/bzrlib/repofmt/groupcompress_repo.py 2009-09-24 22:01:02 +0000
+++ b/bzrlib/repofmt/groupcompress_repo.py 2009-09-24 22:10:50 +0000
@@ -1012,31 +1012,50 @@
trees = dict((t.get_revision_id(), t) for
t in self.revision_trees(required_trees))
+ interesting_root_key = None
+ interesting_ids_by_root = None
# Calculate the deltas
for revision in revisions:
if not revision.parent_ids:
old_tree = self.revision_tree(_mod_revision.NULL_REVISION)
+ old_path_root_key = None
old_interesting_ids = ()
else:
old_tree = trees[revision.parent_ids[0]]
- if specific_fileids:
- (old_interesting_ids,
- _) = old_tree.inventory._expand_fileids_to_parents_and_children(
- specific_fileids)
+ old_path_root_key = \
+ old_tree.inventory.parent_id_basename_to_file_id.key()
tree = trees[revision.revision_id]
if specific_fileids is None:
yield tree.changes_from(old_tree)
continue
- (all_interesting_ids,
- _) = tree.inventory._expand_fileids_to_parents_and_children(
+ tree_path_root_key = \
+ tree.inventory.parent_id_basename_to_file_id.key()
+ if tree_path_root_key == interesting_root_key:
+ interesting_ids = interesting_ids_by_root
+ else:
+ (interesting_ids,
+ _) = tree.inventory._expand_fileids_to_parents_and_children(
+ specific_fileids)
+ interesting_root_key = tree_path_root_key
+ interesting_ids_by_root = interesting_ids
+
+ if (old_path_root_key != tree_path_root_key
+ and old_path_root_key is not None):
+ # The old tree had a different tree layout than the current one
+ # so we need to expand again
+ (old_interesting_ids,
+ _) = old_tree.inventory._expand_fileids_to_parents_and_children(
specific_fileids)
- all_interesting_ids.update(old_interesting_ids)
- # We should probably also do the expansion on the other side...
+ # We don't mutate interesting_ids in place, because it is being
+ # cached
+ old_interesting_ids.update(interesting_ids)
+ interesting_ids = old_interesting_ids
+
delta = []
for one_delta in tree.iter_changes(old_tree):
file_id = one_delta[0]
- if file_id in all_interesting_ids:
+ if file_id in interesting_ids:
delta.append(one_delta)
yield _mod_delta._iter_changes_to_tree_delta(delta,
include_root=False) # default for changes_from()
More information about the bazaar-commits
mailing list