Skip to content

Commit 4bed03f

Browse files
committed
docs(documentation): Add details for cache key and -purging
1 parent ce12474 commit 4bed03f

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

rfcs/0017-incremental-build.md

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ The cache consists of two main parts:
7676

7777
#### cache-info.json
7878

79-
````json
79+
````jsonc
8080
{
8181
"timestamp": 1734005532124,
8282
"cacheKey": "project-name-1.0.0-bb3a3262d893fcb9adf16bff63f",
@@ -94,26 +94,33 @@ The cache consists of two main parts:
9494
"patterns": []
9595
},
9696
"inputs": {
97-
// Map of logical paths read to their content hashes
97+
// Map of logical paths read to their content hashes
9898
"/resources/project/namespace/Component.js": "d41d8cd98f00b204e9899998ecf8427e"
9999
},
100100
"outputs": {
101-
// Map of logical paths written to their content hashes
101+
// Map of logical paths written to their content hashes
102102
"/resources/project/namespace/Component.js": "c1c77edc5c689a471b12fe8ba79c51d1"
103103
}
104104
}
105105
}],
106106
"sourceMetadata": {
107-
// Map of source paths to their content hashes
107+
// Map of source paths to their content hashes
108108
"/resources/project/namespace/Component.js": "d41d8cd98f00b204e9800998ecf8427e"
109109
}
110110
}
111111
````
112112

113113
**cacheKey**
114114

115-
The cache key can be used to identify the cache. It shall be based on the project's name and version as well as a SHA256 hash of the versions of the relevant UI5 Tooling modules (`@ui5/project`, `@ui5/builder`
116-
`@ui5/fs`), the names and versions of the project's dependencies and the current build configuration (ui5.yaml + CLI parameters). This shall allow the UI5 Tooling to determine whether the cache is still valid or not.
115+
The cache key can be used to identify the cache for a project. It shall be based on the project's name and package version, as well as a SHA256 hash compiled from the following information:
116+
117+
* The versions of all UI5 CLI packages used to create the cache: `@ui5/project`, `@ui5/builder` and `@ui5/fs`
118+
* Different UI5 CLI versions must produce a new cache. Alternatively, we could introduce a dedicated "cache version" that is incremented whenever a breaking change to the cache format is introduced. This would allow reusing the cache across minor UI5 CLI updates.
119+
* The relevant build configuration (ui5.yaml + CLI parameters).
120+
* Changes in the build configuration must result in dedicated cache.
121+
* Some configuration options might not be relevant for the build process (e.g. server configuration). Those could be excluded from the hash calculation to improve cache reusability.
122+
* _**To be decided:** the names and versions of all UI5 project in the dependency tree_
123+
* Changes in dependencies might affect the build result of the current project. However, relying on resource-level cache invalidation might be sufficient to detect such changes.
117124

118125
**taskCache**
119126

@@ -142,7 +149,9 @@ The directory structure is flat and efficient. A global `cas/` directory stores
142149
└── cache-info.json
143150
```
144151

145-
All unique file contents from all projects and their builds are stored **once** in the global `cas` directory, named by their content hash. This automatic deduplication leads to significant disk space savings.
152+
Besides the `cas` directory, each project has its own directory named after its cache key. This directory contains only the `cache-info.json` file for that project.
153+
154+
All unique file contents from all projects and their builds are stored **once** in the global `cas` directory, named by their content hash.
146155

147156
![Diagram illustrating the creation of a build cache](./resources/0017-incremental-build/Create_Cache.png)
148157

@@ -174,6 +183,10 @@ A mechanism to purge unused cache on disk is required. The cache can grow very l
174183

175184
This should probably use some sort of LRU-cache to purge unused cache entries dynamically. The same mechanism could be applied to the npm artifacts downloaded by UI5 Tooling.
176185

186+
To avoid slowing down core commands, the purge check should run as a non-blocking process after a successful ui5 build or ui5 serve command completes. This process checks if either of the configured thresholds (age or size) has been exceeded. If so, it proceeds with the purge.
187+
188+
A dedicated command, such as `ui5 cache clean`, should be introduced in addition. This command allows users to manually trigger a cache purge, providing options to specify criteria such as maximum age or size for cache entries to be removed. Similarly, a command `ui5 cache verify` could be provided to check the integrity of the cache.
189+
177190
### Watch Mode
178191

179192
The build API should provide a "watch" mode that will re-trigger the build when a source file is modified. The watch mode shall select the projects to watch based on which projects have been requested to be built. If a [UI5 Tooling workspace](https://sap.github.io/ui5-tooling/stable/pages/Workspace/) is used, this can be fine-tuned in the workspace configuration.

0 commit comments

Comments
 (0)