Skip to content

Commit fd15217

Browse files
edoardopirovanoaeisenberg
authored andcommitted
Expand disk cache evaluator options
1 parent 1d03702 commit fd15217

5 files changed

Lines changed: 45 additions & 2 deletions

File tree

extensions/ql-vscode/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## [UNRELEASED]
44

5+
- Introduce evaluator options for saving intermediate results to the disk cache, and for limiting the size of this cache. [#593](https://github.com/github/vscode-codeql/pull/593)
56
- Respect the `codeQL.runningQueries.numberOfThreads` setting when creating SARIF files during result interpretation. [#771](https://github.com/github/vscode-codeql/pull/771)
67
- Allow using raw LGTM project slugs for fetching LGTM databases. [#769](https://github.com/github/vscode-codeql/pull/769)
78
- Better error messages when BQRS interpretation fails to produce SARIF. [#770](https://github.com/github/vscode-codeql/pull/770)

extensions/ql-vscode/package.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,20 @@
123123
"maximum": 1024,
124124
"description": "Number of threads for running queries."
125125
},
126+
"codeQL.runningQueries.saveCache": {
127+
"type": "boolean",
128+
"default": false,
129+
"description": "Aggressively save intermediate results to the disk cache. This advanced option is not recommended as it will greatly increase disk usage and evaluation time, but it may speed up subsequent queries if they are similar."
130+
},
131+
"codeQL.runningQueries.cacheSize": {
132+
"type": [
133+
"integer",
134+
"null"
135+
],
136+
"default": null,
137+
"minimum": 1024,
138+
"description": "Maximum size of the disk cache (in MB). Leave blank to allow the evaluator to automatically adjust the size of the disk cache based on the size of the codebase and the complexity of the queries being executed."
139+
},
126140
"codeQL.runningQueries.timeout": {
127141
"type": [
128142
"integer",

extensions/ql-vscode/src/config.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ export interface DistributionConfig {
7373

7474
const RUNNING_QUERIES_SETTING = new Setting('runningQueries', ROOT_SETTING);
7575
const NUMBER_OF_THREADS_SETTING = new Setting('numberOfThreads', RUNNING_QUERIES_SETTING);
76+
const SAVE_CACHE_SETTING = new Setting('saveCache', RUNNING_QUERIES_SETTING);
77+
const CACHE_SIZE_SETTING = new Setting('cacheSize', RUNNING_QUERIES_SETTING);
7678
const TIMEOUT_SETTING = new Setting('timeout', RUNNING_QUERIES_SETTING);
7779
const MEMORY_SETTING = new Setting('memory', RUNNING_QUERIES_SETTING);
7880
const DEBUG_SETTING = new Setting('debug', RUNNING_QUERIES_SETTING);
@@ -85,12 +87,14 @@ export const AUTOSAVE_SETTING = new Setting('autoSave', RUNNING_QUERIES_SETTING)
8587
export const PAGE_SIZE = new Setting('pageSize', RESULTS_DISPLAY_SETTING);
8688

8789
/** When these settings change, the running query server should be restarted. */
88-
const QUERY_SERVER_RESTARTING_SETTINGS = [NUMBER_OF_THREADS_SETTING, MEMORY_SETTING, DEBUG_SETTING];
90+
const QUERY_SERVER_RESTARTING_SETTINGS = [NUMBER_OF_THREADS_SETTING, SAVE_CACHE_SETTING, CACHE_SIZE_SETTING, MEMORY_SETTING, DEBUG_SETTING];
8991

9092
export interface QueryServerConfig {
9193
codeQlPath: string;
9294
debug: boolean;
9395
numThreads: number;
96+
saveCache: boolean;
97+
cacheSize: number;
9498
queryMemoryMb?: number;
9599
timeoutSecs: number;
96100
onDidChangeConfiguration?: Event<void>;
@@ -194,6 +198,14 @@ export class QueryServerConfigListener extends ConfigListener implements QuerySe
194198
return NUMBER_OF_THREADS_SETTING.getValue<number>();
195199
}
196200

201+
public get saveCache(): boolean {
202+
return SAVE_CACHE_SETTING.getValue<boolean>();
203+
}
204+
205+
public get cacheSize(): number {
206+
return CACHE_SIZE_SETTING.getValue<number | null>() || 0;
207+
}
208+
197209
/** Gets the configured query timeout, in seconds. This looks up the setting at the time of access. */
198210
public get timeoutSecs(): number {
199211
return TIMEOUT_SETTING.getValue<number | null>() || 0;
@@ -236,7 +248,6 @@ export class CliConfigListener extends ConfigListener implements CliConfig {
236248
return NUMBER_OF_TEST_THREADS_SETTING.getValue();
237249
}
238250

239-
240251
public get numberThreads(): number {
241252
return NUMBER_OF_THREADS_SETTING.getValue<number>();
242253
}

extensions/ql-vscode/src/queryserver-client.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,15 @@ export class QueryServerClient extends DisposableObject {
136136
const ramArgs = await this.cliServer.resolveRam(this.config.queryMemoryMb, progressReporter);
137137
const args = ['--threads', this.config.numThreads.toString()].concat(ramArgs);
138138

139+
if (this.config.saveCache) {
140+
args.push('--save-cache');
141+
}
142+
143+
if (this.config.cacheSize > 0) {
144+
args.push('--max-disk-cache');
145+
args.push(this.config.cacheSize.toString());
146+
}
147+
139148
if (await this.supportsDatabaseRegistration()) {
140149
args.push('--require-db-registration');
141150
}

extensions/ql-vscode/src/vscode-tests/minimal-workspace/config.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ describe('config listeners', function() {
6464
name: 'codeQL.runningQueries.numberOfThreads',
6565
property: 'numThreads',
6666
values: [0, 1]
67+
}, {
68+
name: 'codeQL.runningQueries.saveCache',
69+
property: 'saveCache',
70+
values: [false, true]
71+
}, {
72+
name: 'codeQL.runningQueries.cacheSize',
73+
property: 'cacheSize',
74+
values: [0, 1]
6775
}, {
6876
name: 'codeQL.runningQueries.memory',
6977
property: 'queryMemoryMb',

0 commit comments

Comments
 (0)