Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(518)

Unified Diff: tools/findit/findit_for_crash.py

Issue 510163002: [Findit] Fix blame for GIT and uptake bug fix. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reuse threads in a pool. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/findit/findit_for_crash.py
diff --git a/tools/findit/findit_for_crash.py b/tools/findit/findit_for_crash.py
index 50f12d85618577f291298b69faba15029d205123..886e757ef7474dbcdbf28aa4689d3be7ef0937f9 100644
--- a/tools/findit/findit_for_crash.py
+++ b/tools/findit/findit_for_crash.py
@@ -3,7 +3,7 @@
# found in the LICENSE file.
import os
-from threading import Lock, Thread
+from threading import Lock
import blame
from common import utils
@@ -139,8 +139,8 @@ def FindMatch(revisions_info_map, file_to_revision_info, file_to_crash_info,
Matches, a set of match objects.
"""
matches = match_set.MatchSet(codereview_api_url)
- threads = []
+ tasks = []
# Iterate through the crashed files in the stacktrace.
for crashed_file_path in file_to_crash_info:
# Ignore header file.
@@ -172,17 +172,16 @@ def FindMatch(revisions_info_map, file_to_revision_info, file_to_crash_info,
revision = revisions_info_map[cl]
- match_thread = Thread(
- target=GenerateMatchEntry,
- args=[matches, revision, cl, changed_file_path, functions,
+ tasks.append({
+ 'function': GenerateMatchEntry,
+ 'args': [matches, revision, cl, changed_file_path, functions,
component_path, component_name, crashed_line_numbers,
stack_frame_nums, file_change_type,
- repository_parser])
- threads.append(match_thread)
- match_thread.start()
+ repository_parser]
+ })
- for match_thread in threads:
- match_thread.join()
+ # Run all the tasks.
+ crash_utils.RunTasks(tasks)
matches.RemoveRevertedCLs()
@@ -241,8 +240,8 @@ def FindMatchForCallstack(
components)
callstack_priority = callstack.priority
+ tasks = []
# Iterate through all components and create new thread for each component.
- threads = []
for component_path in component_dict:
# If the component to consider in this callstack is not in the parsed list
# of components, ignore this one.
@@ -251,15 +250,14 @@ def FindMatchForCallstack(
changelog = component_to_changelog_map[component_path]
file_to_crash_info = component_dict.GetFileDict(component_path)
- t = Thread(
- target=FindMatchForComponent,
- args=[component_path, file_to_crash_info, changelog,
- callstack_priority, results, results_lock])
- threads.append(t)
- t.start()
+ tasks.append({
+ 'function': FindMatchForComponent,
+ 'args': [component_path, file_to_crash_info, changelog,
+ callstack_priority, results, results_lock]
+ })
- for t in threads:
- t.join()
+ # Run all the tasks.
+ crash_utils.RunTasks(tasks)
def FindMatchForStacktrace(stacktrace, components,
@@ -320,18 +318,17 @@ def FindMatchForStacktrace(stacktrace, components,
revisions,
file_to_revision_map)
+ tasks = []
# Create separate threads for each of the call stack in the stacktrace.
- threads = []
for callstack in stacktrace.stack_list:
- t = Thread(
- target=FindMatchForCallstack,
- args=[callstack, components, component_to_changelog_map,
- results, results_lock])
- threads.append(t)
- t.start()
+ tasks.append({
+ 'function': FindMatchForCallstack,
+ 'args': [callstack, components, component_to_changelog_map,
+ results, results_lock]
+ })
- for t in threads:
- t.join()
+ # Run all the tasks.
+ crash_utils.RunTasks(tasks)
return results
@@ -477,8 +474,8 @@ def GenerateReasonForMatches(matches):
pretty_file_names = crash_utils.PrettifyList(file_names)
# Add the reason, break because we took care of the rest of the files.
- file_string += '(%s)' % crash_utils.PrettifyFrameInfo(
- stack_frame_indices, function_list)
+ file_string += ('(and is part of stack %s)' %
+ crash_utils.PrettifyFrameInfo(stack_frame_indices, function_list))
reason.append(file_string % pretty_file_names)
break
@@ -522,8 +519,8 @@ def CombineMatches(matches):
if match.min_distance_info:
file_name, min_crashed_line, min_changed_line = match.min_distance_info
match.reason += \
- ('Minimum distance from crashed line to changed line: %d. '
- '(File: %s, Crashed on: %d, Changed: %d).\n' %
+ ('\nMinimum distance from crash line to modified line: %d. '
+ '(file: %s, crashed on: %d, modified: %d).\n' %
(match.min_distance, file_name, min_crashed_line, min_changed_line))
return combined_matches
@@ -668,8 +665,8 @@ def FindItForCrash(stacktrace_list,
if result:
return_message = (
- 'No CL in the regression changes the crashed files. The result is '
- 'the blame information.')
+ 'No CL in the regression range changes the crashed files. '
+ 'The result is the blame information.')
# When findit could not find any CL that changes file in stacktrace or if
# if cannot get any blame information, return a message saying that no

Powered by Google App Engine
This is Rietveld 408576698