feat: Clean cache command#1394
Conversation
83f2262 to
d52c4ad
Compare
7c59782 to
444977d
Compare
c2dc7b8 to
1041695
Compare
dc31834 to
f5def12
Compare
1041695 to
66296d5
Compare
77f7320 to
aa280da
Compare
34fd55f to
7473bd4
Compare
7b17cc0 to
569ff71
Compare
569ff71 to
36fd376
Compare
|
I think the usability of the command could be improved.
|
|
I have tried to improve the situation with the infmration for the execution of the Let me know if there's something more you'd expect. Regarding the size report, there are some considerations we need to be aware of:
I have tried to somehow get advantage of these findings and provide the optimal solution- show metrics for what is fast and provide generic messages. Any other solutions will require certain compromises. |
EditNow the UX of this command is revised! The real issue is enormous cache! Collecting full information about what would be deleted is a haevy work and we simply cannot do it real time. In the end, for the end user it's important what would be deleted! ConfirmationChecking cache at /my/data/dir/.ui5 …
The following cached data will be removed:
• UI5 Framework packages /my/data/dir/.ui5/framework (1 project, 18 libraries, 212 versions)
• Build cache (DB) /my/data/dir/.ui5/buildCache/v0_7 (100.0 KB)
Do you want to continue? (y/N)During cache cleanupIf we now decide to accept purging of the hughe cache, it will take some time cleaning it up. We cannot do anythinbg about it, but simply wait for the fuiles to be deleted. ⠏ UI5 Framework packages …/sap.m/1.52.14/src/sap/m/BarRenderer.js 2.86 sFinal summary✓ Removed UI5 Framework packages (/my/data/dir/.ui5/framework · 1 project, 18 libraries, 212 versions)
✓ Removed Build cache (DB) (/my/data/dir/.ui5/buildCache/v0_7 · 100.0 MB)
Success: Cleaned UI5 Framework packages and Build cache (DB)Hopefully, this is good enough as UX and fast enough, so that developers get feedback what is actually happenning |
|
That's better. On my system it's very fast now: But I think the term I don't really think we need a progress indicator for the deletion process. It is expected to take a while, I would rather not add code just for that. |
3f0d21c to
4d39800
Compare
matz3
left a comment
There was a problem hiding this comment.
I tested it manually and it works as expected now in the relevant cases that typically appear (I did not test any rare race-condition).
The docs (once updated) and the CLI command (options, help, output) should be reviewed by UA. Some terms are not consistent (e.g. Orphaned framework data vs UI5 Framework packages).
So far, I did not review any of the tests.
|
Hi @KlattG Would you take a look please? Here are the relevant resources, mentioned in this comment: #1394 (review)
Cheers |
Co-authored-by: Günter Klatt <guenter.klatt@sap.com>
Co-authored-by: Günter Klatt <guenter.klatt@sap.com>
Co-authored-by: Günter Klatt <guenter.klatt@sap.com>
Co-authored-by: Günter Klatt <guenter.klatt@sap.com>
Co-authored-by: Günter Klatt <guenter.klatt@sap.com>
Co-authored-by: Günter Klatt <guenter.klatt@sap.com>
Co-authored-by: Günter Klatt <guenter.klatt@sap.com>
Co-authored-by: Günter Klatt <guenter.klatt@sap.com>
Co-authored-by: Günter Klatt <guenter.klatt@sap.com>
Co-authored-by: Günter Klatt <guenter.klatt@sap.com>
|
|
||
| ::: info | ||
| If you have configured a custom data directory via `UI5_DATA_DIR` or `ui5 config set ui5DataDir`, replace `~/.ui5/` with that path. See [Changing UI5 CLI's Data Directory](#changing-ui5-cli-s-data-directory). | ||
| If you have configured a custom data directory via `UI5_DATA_DIR` or `ui5 config set ui5DataDir`, the `ui5 cache clean` command automatically cleans up that location instead of the default `~/.ui5/`. See [Changing UI5 CLI's Data Directory](#changing-ui5-cli-s-data-directory). |
There was a problem hiding this comment.
| If you have configured a custom data directory via `UI5_DATA_DIR` or `ui5 config set ui5DataDir`, the `ui5 cache clean` command automatically cleans up that location instead of the default `~/.ui5/`. See [Changing UI5 CLI's Data Directory](#changing-ui5-cli-s-data-directory). | |
| If you have configured a custom data directory via `UI5_DATA_DIR` or `ui5 config set ui5DataDir`, the `ui5 cache clean` command will clean up that location instead of the default `~/.ui5/`. See [Changing UI5 CLI's Data Directory](#changing-ui5-cli-s-data-directory). |
| - **Build cache (DB)** — build data (`~/.ui5/buildCache/`) | ||
| - **Orphaned framework data** — incomplete framework directories left over from previously interrupted cleanup operations (`~/.ui5/.framework_to_delete_*/`) | ||
|
|
||
| Any missing framework dependencies are downloaded during the next UI5 CLI invocation. |
There was a problem hiding this comment.
| Any missing framework dependencies are downloaded during the next UI5 CLI invocation. | |
| Any required framework dependencies will be re-downloaded during the next UI5 CLI invocation. |
| @@ -0,0 +1,170 @@ | |||
| import path from "node:path"; | |||
There was a problem hiding this comment.
acquireLockSync is not called in the ProjectGraph constructor but rather in the async function _preventCacheClean - Is acquireLockSync still needed or a relict?
| * @returns {string} Absolute path to the locks directory (<code>~/.ui5/locks/</code>) | ||
| */ | ||
| export function getLockDir(ui5DataDir) { | ||
| return path.join(ui5DataDir, "locks"); |
There was a problem hiding this comment.
Previous UI5 CLI versions use path.join(ui5DataDir, "framework", "locks");. Won't this cause clashes now if multiple CLI versions are used in parallel?
If possible, I would prefer to keep using the framework/locks path for framework-dependency related locks
| * If provided, these files are excluded from the scan. | ||
| * @returns {Promise<boolean>} True if any matching non-stale lockfiles are held | ||
| */ | ||
| export async function hasActiveLocks(ui5DataDir, {include, exclude} = {}) { |
There was a problem hiding this comment.
Nitpick: The include/exclude parameters are only ever used for the cleanup lock. I think this could be simplified by providing dedicated functions for the cleanup lock instead of this generic one.
But that's no must-fix for this iteration, just a bit confusing when reading the code
|
|
||
| // Poll until any in-progress cache clean releases its lock, or we time out. | ||
| const POLL_INTERVAL_MS = 200; | ||
| const TIMEOUT_MS = 10000; |
There was a problem hiding this comment.
Should we increase this to 60 seconds for a cache clean to finish?
| * Releases the process-coordination lock held by this graph. | ||
| * Call this when the graph is no longer needed to unblock <code>ui5 cache clean</code>. | ||
| * | ||
| * If not called explicitly, the <code>lockfile</code> package's <code>signal-exit</code> |
There was a problem hiding this comment.
IMHO this public API description goes into too much detail about our internal implementation (which might change)
| * packages are being downloaded, or while those packages are actively referenced | ||
| * within the graph during the build/serve lifecycle. | ||
| * | ||
| * This is necessary because the graph holds references to framework package paths |
There was a problem hiding this comment.
Maybe we can mention that this is called in ui5Framework to make sure the graph is already locked once framework resources (which are affected by the cache clean) are used
| "(~/.ui5/framework/)\n" + | ||
| " Build cache (DB): Build data " + | ||
| "(~/.ui5/buildCache/)\n" + | ||
| " Orphaned framework data: Incomplete directories from previously interrupted cleanups\n" + |
There was a problem hiding this comment.
Nitpick: Is this relevant enough to mention it in the user facing docs?
| return false; | ||
| } | ||
|
|
||
| for (const lockFileName of lockFiles) { |
There was a problem hiding this comment.
Maybe use Promise.all for checking multiple locks concurrently?
|
I think we should discuss this topic again in the team and reconsider the priority. Things got more complex than expected and maybe it's worth starting the concept work from scratch again sometime later this year. |
The command completely cleans the cache by removing the cache files as well as cleaning up the SQLite records.
It does not wipe out the SQLite DB file(s)
JIRA: CPOUI5FOUNDATION-891