bisect-kit: cache some git operations
On a machine with slow disk io, this change could reduce
bisect_cr_localbuild_internal.py init time from 8 to 3.5 minutes.
BUG=b:157413258
TEST=./bisect_cr_localbuild_internal.py init --old 84.0.4142.0 --new 84.0.4147.0
Change-Id: I423c3df56eaa17acdd3bbe882b61fb99cde03fa7
diff --git a/bisect_kit/codechange.py b/bisect_kit/codechange.py
index a087667..56fffe1 100644
--- a/bisect_kit/codechange.py
+++ b/bisect_kit/codechange.py
@@ -916,6 +916,11 @@
logger.info('get_specs_and_revlist: old = %s, new = %s', old, new)
revlist = []
+ # Enable cache for repetitive git operations. The space complixity is
+ # O(number of candidates).
+ git_util.get_commit_metadata.enable_cache()
+ git_util.get_file_from_revision.enable_cache()
+
# step 1, find all float and fixed specs in the given range.
fixed_specs = self.spec_manager.collect_fixed_spec(old, new)
assert fixed_specs
@@ -997,6 +1002,8 @@
# operations when switch git versions. Be conservative now. We can cache
# more if we observed more slow git operations later.
git_util.fast_lookup.disable()
+ git_util.get_commit_metadata.disable_cache()
+ git_util.get_file_from_revision.disable_cache()
return fixed_specs, float_specs, revlist