зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1590820 Improve preview pane performance in 'mach try fuzzy -s' r=ahal
Refactored the recursion to improve its reliability, and added a caching layer. Differential Revision: https://phabricator.services.mozilla.com/D50267 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
8727ad510c
Коммит
9543684c8f
|
@ -25,33 +25,43 @@ def plain_data(tasklist):
|
||||||
print("\n".join(sorted(s.strip("'") for s in tasklist.split())))
|
print("\n".join(sorted(s.strip("'") for s in tasklist.split())))
|
||||||
|
|
||||||
|
|
||||||
def find_dependencies(graph, task):
|
def find_all_dependencies(graph, tasklist):
|
||||||
|
all_dependencies = dict()
|
||||||
|
|
||||||
|
def find_dependencies(task):
|
||||||
dependencies = set()
|
dependencies = set()
|
||||||
dependencies.add(task)
|
dependencies.add(task)
|
||||||
|
if task in all_dependencies:
|
||||||
|
return all_dependencies[task]
|
||||||
for dep in graph.get(task, list()):
|
for dep in graph.get(task, list()):
|
||||||
dependencies.update(find_dependencies(graph, dep))
|
all_dependencies[task] = find_dependencies(dep)
|
||||||
|
dependencies.update(all_dependencies[task])
|
||||||
return dependencies
|
return dependencies
|
||||||
|
|
||||||
|
|
||||||
def find_all_dependencies(graph, tasklist):
|
|
||||||
full_deps = set()
|
full_deps = set()
|
||||||
for task in tasklist:
|
for task in tasklist:
|
||||||
full_deps.update(find_dependencies(graph, task))
|
full_deps.update(find_dependencies(task))
|
||||||
|
|
||||||
# Since these have been asked for, they're not inherited dependencies.
|
# Since these have been asked for, they're not inherited dependencies.
|
||||||
return sorted(full_deps - set(tasklist))
|
return sorted(full_deps - set(tasklist))
|
||||||
|
|
||||||
|
|
||||||
def find_dependency_durations(graph, task, current_duration, durations):
|
def find_longest_path(graph, tasklist, duration_data):
|
||||||
current_duration += durations.get(task, 0.0)
|
|
||||||
durations = [find_dependency_durations(graph, dep, current_duration, durations)
|
dep_durations = dict()
|
||||||
|
|
||||||
|
def find_dependency_durations(task):
|
||||||
|
if task in dep_durations:
|
||||||
|
return dep_durations[task]
|
||||||
|
|
||||||
|
durations = [find_dependency_durations(dep)
|
||||||
for dep in graph.get(task, list())]
|
for dep in graph.get(task, list())]
|
||||||
durations.append(current_duration)
|
durations.append(0.0)
|
||||||
return max(durations)
|
md = max(durations) + duration_data.get(task, 0.0)
|
||||||
|
dep_durations[task] = md
|
||||||
|
return md
|
||||||
|
|
||||||
|
longest_paths = [find_dependency_durations(task) for task in tasklist]
|
||||||
def find_longest_path(graph, tasklist, durations):
|
|
||||||
longest_paths = [find_dependency_durations(graph, task, 0.0, durations) for task in tasklist]
|
|
||||||
return max(longest_paths)
|
return max(longest_paths)
|
||||||
|
|
||||||
|
|
||||||
|
@ -88,24 +98,14 @@ def duration_data(durations_file, graph_cache_file, quantiles_file, tasklist):
|
||||||
dependency_duration += int(durations.get(task, 0.0))
|
dependency_duration += int(durations.get(task, 0.0))
|
||||||
|
|
||||||
total_requested_duration = 0.0
|
total_requested_duration = 0.0
|
||||||
|
for task in tasklist:
|
||||||
|
duration = int(durations.get(task, 0.0))
|
||||||
|
total_requested_duration += duration
|
||||||
output = ""
|
output = ""
|
||||||
duration_width = 5 # show five numbers at most.
|
duration_width = 5 # show five numbers at most.
|
||||||
|
|
||||||
max_columns = int(os.environ['FZF_PREVIEW_COLUMNS'])
|
max_columns = int(os.environ['FZF_PREVIEW_COLUMNS'])
|
||||||
|
|
||||||
output = "{:>{width}}\n".format("Duration", width=max_columns)
|
|
||||||
for task in tasklist:
|
|
||||||
duration = int(durations.get(task, 0.0))
|
|
||||||
total_requested_duration += duration
|
|
||||||
output += "{:{align}{width}} {:{nalign}{nwidth}}s\n".format(
|
|
||||||
task,
|
|
||||||
duration,
|
|
||||||
align='<',
|
|
||||||
width=max_columns-(duration_width+2), # 2: space and 's'
|
|
||||||
nalign='>',
|
|
||||||
nwidth=duration_width,
|
|
||||||
)
|
|
||||||
|
|
||||||
total_requested_duration = timedelta(seconds=total_requested_duration)
|
total_requested_duration = timedelta(seconds=total_requested_duration)
|
||||||
total_dependency_duration = timedelta(seconds=dependency_duration)
|
total_dependency_duration = timedelta(seconds=dependency_duration)
|
||||||
|
|
||||||
|
@ -123,6 +123,19 @@ def duration_data(durations_file, graph_cache_file, quantiles_file, tasklist):
|
||||||
output += "Estimated finish in {} at {}".format(
|
output += "Estimated finish in {} at {}".format(
|
||||||
timedelta(seconds=int(longest_path)),
|
timedelta(seconds=int(longest_path)),
|
||||||
(datetime.now()+timedelta(seconds=longest_path)).strftime("%H:%M"))
|
(datetime.now()+timedelta(seconds=longest_path)).strftime("%H:%M"))
|
||||||
|
|
||||||
|
output += "{:>{width}}\n".format("Duration", width=max_columns)
|
||||||
|
for task in tasklist:
|
||||||
|
duration = int(durations.get(task, 0.0))
|
||||||
|
output += "{:{align}{width}} {:{nalign}{nwidth}}s\n".format(
|
||||||
|
task,
|
||||||
|
duration,
|
||||||
|
align='<',
|
||||||
|
width=max_columns-(duration_width+2), # 2: space and 's'
|
||||||
|
nalign='>',
|
||||||
|
nwidth=duration_width,
|
||||||
|
)
|
||||||
|
|
||||||
print(output)
|
print(output)
|
||||||
|
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче