summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-05-08 21:34:19 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-05-11 17:45:09 +0900
commit01a02a9a01c31ece723f88327877781a7a0e24fa (patch)
treebc30fc7af10bb2665980b3458929e92a17ef0850
parent3d9491dde89621a52b8f526609bf9647d6e4be23 (diff)
downloadbuildstream-01a02a9a01c31ece723f88327877781a7a0e24fa.tar.gz
_workspaces.py: Use file mtime for workspace cache keys instead of checksumming
The rationale for this is basically: o A workspace is completely local o A cache key for a workspace is used to determine if the workspace has changed or not o Within reason, one should not expect buildstream to detect a change without a file's mtime having been modified On my machine, it takes about 1 minute to checksum 11GB of WebKit checkout, that is annoyingly a long time. With this change, it takes only 5 seconds. Not perfect, but it's a start. This is related to issues #294, #295 and #392
-rw-r--r--buildstream/_workspaces.py15
1 files changed, 6 insertions, 9 deletions
diff --git a/buildstream/_workspaces.py b/buildstream/_workspaces.py
index 828343538..f6cdeb88b 100644
--- a/buildstream/_workspaces.py
+++ b/buildstream/_workspaces.py
@@ -173,17 +173,14 @@ class Workspace():
#
def get_key(self, recalculate=False):
def unique_key(filename):
- if os.path.isdir(filename):
- return "0"
- elif os.path.islink(filename):
- return "1"
-
try:
- return utils.sha256sum(filename)
- except FileNotFoundError as e:
+ stat = os.lstat(filename)
+ except OSError as e:
raise LoadError(LoadErrorReason.MISSING_FILE,
- "Failed loading workspace. Did you remove the "
- "workspace directory? {}".format(e))
+ "Failed to stat file in workspace: {}".format(e))
+
+ # Use the mtime of any file with sub second precision
+ return stat.st_mtime_ns
if recalculate or self._key is None:
fullpath = self.get_absolute_path()