From 9b846ad7728fe4e77e1cdd81bf3b0220c2b1da93 Mon Sep 17 00:00:00 2001 From: Tristan Van Berkom Date: Tue, 8 May 2018 21:34:19 +0900 Subject: _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 --- buildstream/_workspaces.py | 15 ++++++--------- 1 file 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() -- cgit v1.2.1