bisect-kit: make git_util.get_rev_by_time faster
On a machine with slow disk io, this change could reduce
bisect_cr_localbuild_internal.py init time from 41 to 8 minutes.
This also helps for init of chromeos local build bisections, but not
much (say, from 8 to 4 minutes).
BUG=b:157413258
TEST=./bisect_cr_localbuild_internal.py init --old 84.0.4142.0 --new 84.0.4147.0
Change-Id: Ide347534c1cfc8062939dda46c5594c4817f4606
diff --git a/bisect_kit/codechange.py b/bisect_kit/codechange.py
index 6f7b8c1..a087667 100644
--- a/bisect_kit/codechange.py
+++ b/bisect_kit/codechange.py
@@ -930,6 +930,8 @@
for spec in float_specs:
self.spec_manager.parse_spec(spec)
+ git_util.fast_lookup.optimize(
+ (float_specs[0].timestamp, float_specs[-1].timestamp))
# step 2, synthesize all fixed specs in the range from float specs.
specs = float_specs + [fixed_specs[-1]]
action_groups = []
@@ -991,6 +993,11 @@
this_action_groups)
revlist.append(fixed_specs[associated_pairs[-1][0]].name)
+ # Disable cache because there might be write or even destructive git
+ # 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()
+
return fixed_specs, float_specs, revlist
def save_action_groups_between_releases(self, old, new, action_groups):