aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/actions/Artifact.java
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2016-06-16 00:49:06 +0000
committerGravatar Yue Gan <yueg@google.com>2016-06-16 09:04:07 +0000
commit0e17046797f6cfed21755f2eed7c52c0a340d40c (patch)
tree1d965e43c4d0bcf9c6f1e45c95f742ec939bd6ac /src/main/java/com/google/devtools/build/lib/actions/Artifact.java
parent8f5d9d55ce2974c13f57f7b08ab39f2a9dc64028 (diff)
Description redacted.
-- MOS_MIGRATED_REVID=125013752
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/actions/Artifact.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/actions/Artifact.java7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/actions/Artifact.java b/src/main/java/com/google/devtools/build/lib/actions/Artifact.java
index 975c292720..b3b86823da 100644
--- a/src/main/java/com/google/devtools/build/lib/actions/Artifact.java
+++ b/src/main/java/com/google/devtools/build/lib/actions/Artifact.java
@@ -147,6 +147,7 @@ public class Artifact
}
};
+ private final int hashCode;
private final Path path;
private final Root root;
private final PathFragment execPath;
@@ -180,6 +181,7 @@ public class Artifact
throw new IllegalArgumentException(execPath + ": illegal execPath for " + path
+ " (root: " + root + ")");
}
+ this.hashCode = path.hashCode();
this.path = path;
this.root = root;
this.execPath = execPath;
@@ -572,7 +574,10 @@ public class Artifact
@Override
public final int hashCode() {
- return path.hashCode();
+ // This is just path.hashCode(). We cache a copy in the Artifact object to reduce LLC misses
+ // during operations which build a HashSet out of many Artifacts. This is a slight loss for
+ // memory but saves ~1% overall CPU in some real builds.
+ return hashCode;
}
@Override