diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2018-05-08 21:34:19 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2018-05-08 21:37:46 +0900 |
commit | 9b846ad7728fe4e77e1cdd81bf3b0220c2b1da93 (patch) | |
tree | a0050aa9de90f315bde98d1203dea130ffa75736 | |
parent | 1ec80edc1e80bf03b5eeca500d62da64977a24dd (diff) | |
download | buildstream-tristan/optimize-workspace-keys.tar.gz |
_workspaces.py: Use file mtime for workspace cache keys instead of checksummingtristan/optimize-workspace-keys
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.py | 15 |
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() |