diff options
author | 2016-05-10 14:05:14 +0000 | |
---|---|---|
committer | 2016-05-10 15:57:21 +0000 | |
commit | 9dc32111d5b6c1c7c5eaf39efad5fef75327ee75 (patch) | |
tree | e2f8f234725b038507c73f07fa1aa432312c3a9d | |
parent | aae3e40985d15a6311d2a336cd99fd8c2368bd78 (diff) |
Remove unnecessary sorting from CppCompileAction.computeKey().
This showed up as a hotspot (3% of CPU time) in profiles of large C++ builds.
--
MOS_MIGRATED_REVID=121943041
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java index e40ddc8843..721ad0f889 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java @@ -1093,19 +1093,6 @@ public class CppCompileAction extends AbstractAction return context.getDeclaredIncludeSrcs(); } - /** - * Return explicit header files (i.e., header files explicitly listed) in an order - * that is stable between builds. - */ - protected final List<PathFragment> getDeclaredIncludeSrcsInStableOrder() { - List<PathFragment> paths = new ArrayList<>(); - for (Artifact declaredIncludeSrc : context.getDeclaredIncludeSrcs()) { - paths.add(declaredIncludeSrc.getExecPath()); - } - Collections.sort(paths); // Order is not important, but stability is. - return paths; - } - @Override public ResourceSet estimateResourceConsumption(Executor executor) { return executor.getContext(actionContext).estimateResourceConsumption(this); @@ -1142,8 +1129,13 @@ public class CppCompileAction extends AbstractAction */ f.addPaths(context.getDeclaredIncludeDirs()); f.addPaths(context.getDeclaredIncludeWarnDirs()); - f.addPaths(getDeclaredIncludeSrcsInStableOrder()); - f.addPaths(Artifact.asSortedPathFragments(getMandatoryInputs())); + for (Artifact declaredIncludeSrc : context.getDeclaredIncludeSrcs()) { + f.addPath(declaredIncludeSrc.getExecPath()); + } + f.addInt(0); // mark the boundary between input types + for (Artifact input : getMandatoryInputs()) { + f.addPath(input.getExecPath()); + } return f.hexDigestAndReset(); } @@ -1252,9 +1244,9 @@ public class CppCompileAction extends AbstractAction message.append('\n'); } - for (PathFragment path : getDeclaredIncludeSrcsInStableOrder()) { + for (Artifact src : getDeclaredIncludeSrcs()) { message.append(" Declared include source: "); - message.append(ShellEscaper.escapeString(path.getPathString())); + message.append(ShellEscaper.escapeString(src.getExecPathString())); message.append('\n'); } |