YamlCache reads the entire file's contents to see if the file is in the cache
Background
YamlCache is a class that speeds up the parsing and provenancing of yaml by maintaining a cache of yaml parsing that is persistent across BuildStream executions. Currently, it reads all of a file's contents to decide whether it has changed since it was put in the cache. There should be an easier way to do that - statting a file and comparing its mtime works in most cases.
There are currently three distinct cases where we load yaml, listed in order of most to least common:
- Element file from a checked-out project. mtime is very suitable for this.
- Element file from a junctioned project. mtime is not suitable for this because these files are a checked-out Source each buildstream invocation.
- Element file from a workspace of a junctioned project. mtime should be suitable for this, but I am not sure whether it actually loads the file from the workspace.
Task description
-
Write a test case to check whether changes in a workspace of a junction are being picked up. -
If not being read, fix this.
-
-
Use the file's mtime when checking for changes in an element in a checked-out project, or a workspaced junctioned project. -
Use the junctioning element's cache key when checking for changes in an element in a junctioned project - plus potentially changes to the Element API if acquiring this information breaks encapsulation. -
Ensure that the yamlcache is being exercised for element checkouts, junctions and workspaced junctions with tests.
Acceptance Criteria
Unless completely unavoidable, YamlCache does not need to read the contents of a file to know whether it is cached.