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

Unified Diff: tools/clang/scripts/run_tool.py

Issue 2805893003: Make it possible to shard run_too.py invocations. (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/clang/scripts/run_tool.py
diff --git a/tools/clang/scripts/run_tool.py b/tools/clang/scripts/run_tool.py
index 53c7d0fc2da2a6b9d7d7d403c3cfb0a1e60a5c38..37ff3cc80f20ed867f91eef3f099e62f8a06e597 100755
--- a/tools/clang/scripts/run_tool.py
+++ b/tools/clang/scripts/run_tool.py
@@ -195,6 +195,9 @@ def main():
action='store_true',
help='regenerate the compile database before running the tool')
parser.add_argument(
+ '--shard',
+ metavar='<n>-of-<count>')
+ parser.add_argument(
'compile_database',
help='path to the directory that contains the compile database')
parser.add_argument(
@@ -226,6 +229,19 @@ def main():
for f in git_filenames
if os.path.splitext(f)[1] in extensions]
+ if args.shard:
+ total_length = len(source_filenames)
+ match = re.match(r'(\d+)-of-(\d+)$', args.shard)
+ # Input is 1-based, but modular arithmetic is 0-based.
+ shard_number = int(match.group(1)) - 1
+ shard_count = int(match.group(2))
+ source_filenames = [
+ f[1] for f in enumerate(sorted(source_filenames))
+ if f[0] % shard_count == shard_number
+ ]
+ print 'Shard %d-of-%d will process %d entries out of %d' % (
+ shard_number, shard_count, len(source_filenames), total_length)
+
dispatcher = _CompilerDispatcher(args.tool, args.tool_args,
args.compile_database,
source_filenames)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698