You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While running tasks concurrently on the same shared cache directory is pretty safe, some other features like the dependency graph cache and the daemon info are not. This can be a problem when multiple commands are being run on different project structures, like changing branches or making refactorings. Related to #9146
Moreover, the current layout of the .cache directory doesn't differentiate which files are safe to be stored across project changes (hashed tasks outputs), and which ones are only being used just for keeping the current state of the application (dep graph cache, daemon info). They are all hoisted and mixed on the same node_modules/.cache/nx directory.
For example, this is the current contents of my node_modules/.cache/nx directory:
Hashed outputs and application state are all bunched up in the same directory. A better solution would be to bundle all hashed outputs on a common tasks or runs directory, like so:
This way, I can be sure that at least the runs directory is safe for sharing
Motivation
Sharing the same cache directories could have a huge impact on CI times, as we can consider .cache/runs as a per-project global cache that can be re-utilized across multiple CI runs without any concurrent writes on the same file. Similar to how other global caches work on npm and yarn.
Aside from that, we would need to agree on not adding any concurrent unsafe outputs to that directory.
Alternate Implementations
The alternative would be to make all application state to be safe for concurrent access, that being as of now the daemon info and dependency graph cache
The text was updated successfully, but these errors were encountered:
Description
While running tasks concurrently on the same shared cache directory is pretty safe, some other features like the dependency graph cache and the daemon info are not. This can be a problem when multiple commands are being run on different project structures, like changing branches or making refactorings. Related to #9146
Moreover, the current layout of the
.cache
directory doesn't differentiate which files are safe to be stored across project changes (hashed tasks outputs), and which ones are only being used just for keeping the current state of the application (dep graph cache, daemon info). They are all hoisted and mixed on the samenode_modules/.cache/nx
directory.For example, this is the current contents of my
node_modules/.cache/nx
directory:Hashed outputs and application state are all bunched up in the same directory. A better solution would be to bundle all hashed outputs on a common
tasks
orruns
directory, like so:This way, I can be sure that at least the
runs
directory is safe for sharingMotivation
Sharing the same cache directories could have a huge impact on CI times, as we can consider
.cache/runs
as a per-project global cache that can be re-utilized across multiple CI runs without any concurrent writes on the same file. Similar to how other global caches work onnpm
andyarn
.Suggested Implementation
As already said, I think better differentiating between safe read-only files and application state would be the way to go. Because of how well the code is structured the only changes (AFAIK) would be related to the file https://github.com/nrwl/nx/blob/master/packages/nx/src/tasks-runner/cache.ts.
Aside from that, we would need to agree on not adding any concurrent unsafe outputs to that directory.
Alternate Implementations
The alternative would be to make all application state to be safe for concurrent access, that being as of now the daemon info and dependency graph cache
The text was updated successfully, but these errors were encountered: