Skip to content

New command: expose --cache-cleanup=overlay base cache cleaning #4082

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions extensions/ql-vscode/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## [UNRELEASED]

- Add new command "CodeQL: Trim Overlay Base Cache" that returns a database to the state prior to overlay evaluation, leaving only base predicates and types that may later be referenced during overlay evaluation.

## 1.17.4 - 10 July 2025

- Fix variant analysis pack creation on some Windows systems [#4068](https://github.com/github/vscode-codeql/pull/4068)
Expand Down
4 changes: 4 additions & 0 deletions extensions/ql-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,10 @@
"command": "codeQL.trimCache",
"title": "CodeQL: Trim Cache"
},
{
"command": "codeQL.trimOverlayBaseCache",
"title": "CodeQL: Trim Overlay Base Cache"
},
{
"command": "codeQL.installPackDependencies",
"title": "CodeQL: Install Pack Dependencies"
Expand Down
1 change: 1 addition & 0 deletions extensions/ql-vscode/src/common/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ export type LocalDatabasesCommands = {
"codeQL.upgradeCurrentDatabase": () => Promise<void>;
"codeQL.clearCache": () => Promise<void>;
"codeQL.trimCache": () => Promise<void>;
"codeQL.trimOverlayBaseCache": () => Promise<void>;

// Explorer context menu
"codeQL.setCurrentDatabase": (uri: Uri) => Promise<void>;
Expand Down
19 changes: 19 additions & 0 deletions extensions/ql-vscode/src/databases/local-databases-ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ export class DatabaseUI extends DisposableObject {
this.handleUpgradeCurrentDatabase.bind(this),
"codeQL.clearCache": this.handleClearCache.bind(this),
"codeQL.trimCache": this.handleTrimCache.bind(this),
"codeQL.trimOverlayBaseCache": this.handleTrimOverlayBaseCache.bind(this),
"codeQLDatabases.chooseDatabaseFolder":
this.handleChooseDatabaseFolder.bind(this),
"codeQLDatabases.chooseDatabaseArchive":
Expand Down Expand Up @@ -688,6 +689,24 @@ export class DatabaseUI extends DisposableObject {
);
}

private async handleTrimOverlayBaseCache(): Promise<void> {
return withProgress(
async () => {
if (
this.queryServer !== undefined &&
this.databaseManager.currentDatabaseItem !== undefined
) {
await this.queryServer.trimOverlayBaseCacheInDatabase(
this.databaseManager.currentDatabaseItem,
);
}
},
{
title: "Removing all overlay-dependent data from cache",
},
);
}

private async handleGetCurrentDatabase(): Promise<string | undefined> {
const dbItem = await this.getDatabaseItemInternal(undefined);
return dbItem?.databaseUri.fsPath;
Expand Down
8 changes: 8 additions & 0 deletions extensions/ql-vscode/src/query-server/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,14 @@ export const trimCache = new RequestType<
ClearCacheResult,
void
>("evaluation/trimCache");
/**
* Trim overlay-dependent data from the cache of a dataset
*/
export const trimOverlayBaseCache = new RequestType<
WithProgressId<TrimCacheParams>,
ClearCacheResult,
void
>("evaluation/trimOverlayBaseCache");

/**
* Clear the pack cache
Expand Down
15 changes: 15 additions & 0 deletions extensions/ql-vscode/src/query-server/query-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
deregisterDatabases,
registerDatabases,
trimCache,
trimOverlayBaseCache,
upgradeDatabase,
} from "./messages";
import type { BaseLogger, Logger } from "../common/logging";
Expand Down Expand Up @@ -142,6 +143,20 @@ export class QueryRunner {
await this.qs.sendRequest(trimCache, params);
}

async trimOverlayBaseCacheInDatabase(dbItem: DatabaseItem): Promise<void> {
if (dbItem.contents === undefined) {
throw new Error(
"Can't trim the overlay base cache in an invalid database.",
);
}

const db = dbItem.databaseUri.fsPath;
const params: TrimCacheParams = {
db,
};
await this.qs.sendRequest(trimOverlayBaseCache, params);
}

public async compileAndRunQueryAgainstDatabaseCore(
dbPath: string,
queries: CoreQueryTarget[],
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy