Commit 9cbe9a07 authored by Josip Sokcevic's avatar Josip Sokcevic Committed by LUCI CQ

Cache condition evaluation results in gclient

Condition evaluation checks are fairly expensive, and turns out we
repeat a lot of checks. All those checks are also done in a single
thread.

With this cache on my workstation, a noop gclient runhooks takes 9.5s.
Without one, it takes 26.2s.

R=gavinmak@google.com

Change-Id: Ie00b7af22cd124d08dd9fd218de77b34bbdfe6ab
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3309823Reviewed-by: 's avatarGavin Mak <gavinmak@google.com>
Reviewed-by: 's avatarDirk Pranke <dpranke@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
parent e6855438
......@@ -643,6 +643,7 @@ class Dependency(gclient_utils.WorkItem, DependencySettings):
def _deps_to_objects(self, deps, use_relative_paths):
"""Convert a deps dict to a dict of Dependency objects."""
deps_to_add = []
cached_conditions = {}
for name, dep_value in deps.items():
should_process = self.should_process
if dep_value is None:
......@@ -651,9 +652,12 @@ class Dependency(gclient_utils.WorkItem, DependencySettings):
condition = dep_value.get('condition')
dep_type = dep_value.get('dep_type')
if condition and not self._get_option('process_all_deps', False):
should_process = should_process and gclient_eval.EvaluateCondition(
condition, self.get_vars())
if condition not in cached_conditions:
cached_conditions[condition] = gclient_eval.EvaluateCondition(
condition, self.get_vars())
should_process = should_process and cached_conditions[condition]
# The following option is only set by the 'revinfo' command.
if self._get_option('ignore_dep_type', None) == dep_type:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment