-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add "CodeQL: Trim Cache" using new mode parameter of evaluation/clearCache
#2931
Conversation
…rCache` The purpose of this change is to add a command to clear the cache except for `cached` predicates. This is the same behaviour as `codeql database cleanup --mode=normal`. In contrast, the existing "CodeQL: Clear Cache" corresponds to `--mode=brutal`. This change depends on adding a new `mode` parameter to the `evaluation/clearCache` method of the query server. This is the same method that the existing "CodeQL: Clear Cache" command targets, which means that this solution will not fail when used with older query servers but will have the same behaviour as the existing command. This somewhat decouples the release process of the VSCode extension and the CodeQL release. Testing done so far: manual (VSCode extension debug run). I haven't seen automated tests for the other command either. As part of adding the new "mode" parameter to the clearCache method, the official query server spec will need to be updated to match `new-messages.ts` here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks reasonable. I have a couple of minor suggestions.
@@ -684,7 +685,7 @@ export class DatabaseUI extends DisposableObject { | |||
); | |||
} | |||
|
|||
private async handleClearCache(): Promise<void> { | |||
private async handleClearCache(mode: "trim" | "clear"): Promise<void> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to extract "trim" | "clear"
into a type
so it can be reused below.
* Trim the cache down to the configured size, but *within* this limit keep anything that | ||
* appears to be even possibly potentially useful in the future. | ||
*/ | ||
export const LIGHT = 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there plans to support LIGHT
and GENTLE
in the future?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not, as they're pretty obscure and there's little practical reason to support them in VSCode. Also, we're renaming "brutal" → "clear" and "normal" → "trim" to be more in line with the VSCode commands, so if you have suggestions on new names for "light" and "gentle", I'm all ears :)
mode: { | ||
trim: CacheTrimmingMode.NORMAL, | ||
clear: CacheTrimmingMode.BRUTAL, | ||
}[mode], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: could you extract this to a function? I find this hard to read.
Closing this PR in favour of the approach taken in #2928 |
The purpose of this change is to add a command to clear the cache
except for
cached
predicates. This is thesame behaviour as
codeql database cleanup --mode=normal
.In contrast, the existing "CodeQL: Clear Cache" corresponds to
--mode=brutal
.This change depends on adding a new
mode
parameter to theevaluation/clearCache
method of the query server. This is the samemethod that the existing "CodeQL: Clear Cache" command targets, which means
that this solution will not fail when used with older query servers
but will have the same behaviour as the existing command.
This somewhat decouples the release process of the VSCode extension and
the CodeQL release.
Testing done so far: manual (VSCode extension debug run). I haven't seen
automated tests for the other command either.
As part of adding the new "mode" parameter to the clearCache method, the
official query server spec will need to be updated to match
new-messages.ts
here.
Checklist
ready-for-doc-review
label there.