Skip to content
Merged
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
1 change: 1 addition & 0 deletions extensions/ql-vscode/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## [UNRELEASED]

- Introduce evaluator options for saving intermediate results to the disk cache (`codeQL.runningQueries.saveCache`) and for limiting the size of this cache (`codeQL.runningQueries.cacheSize`). [#593](https://github.com/github/vscode-codeql/pull/593)
- Respect the `codeQL.runningQueries.numberOfThreads` setting when creating SARIF files during result interpretation. [#771](https://github.com/github/vscode-codeql/pull/771)
- Allow using raw LGTM project slugs for fetching LGTM databases. [#769](https://github.com/github/vscode-codeql/pull/769)
- Better error messages when BQRS interpretation fails to produce SARIF. [#770](https://github.com/github/vscode-codeql/pull/770)
Expand Down
15 changes: 15 additions & 0 deletions extensions/ql-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,21 @@
"maximum": 1024,
"description": "Number of threads for running queries."
},
"codeQL.runningQueries.saveCache": {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably add a scope of "scope": "window" to ensure that downloaded workspaces don't accidentally blow up someone's hard drive.

"type": "boolean",
"default": false,
"scope": "window",
"description": "Aggressively save intermediate results to the disk cache. This may speed up subsequent queries if they are similar. Be aware that using this option will greatly increase disk usage and initial evaluation time."
},
"codeQL.runningQueries.cacheSize": {
"type": [
"integer",
"null"
],
"default": null,
"minimum": 1024,
"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."
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"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."
"description": "Maximum size of the disk cache (in MB). Leave blank or set to 0 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."

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value can't actually be set to 0 because of the "minimum": 1024

},
"codeQL.runningQueries.timeout": {
"type": [
"integer",
Expand Down
15 changes: 13 additions & 2 deletions extensions/ql-vscode/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ export interface DistributionConfig {

const RUNNING_QUERIES_SETTING = new Setting('runningQueries', ROOT_SETTING);
const NUMBER_OF_THREADS_SETTING = new Setting('numberOfThreads', RUNNING_QUERIES_SETTING);
const SAVE_CACHE_SETTING = new Setting('saveCache', RUNNING_QUERIES_SETTING);
const CACHE_SIZE_SETTING = new Setting('cacheSize', RUNNING_QUERIES_SETTING);
const TIMEOUT_SETTING = new Setting('timeout', RUNNING_QUERIES_SETTING);
const MEMORY_SETTING = new Setting('memory', RUNNING_QUERIES_SETTING);
const DEBUG_SETTING = new Setting('debug', RUNNING_QUERIES_SETTING);
Expand All @@ -85,12 +87,14 @@ export const AUTOSAVE_SETTING = new Setting('autoSave', RUNNING_QUERIES_SETTING)
export const PAGE_SIZE = new Setting('pageSize', RESULTS_DISPLAY_SETTING);

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

export interface QueryServerConfig {
codeQlPath: string;
debug: boolean;
numThreads: number;
saveCache: boolean;
cacheSize: number;
queryMemoryMb?: number;
timeoutSecs: number;
onDidChangeConfiguration?: Event<void>;
Expand Down Expand Up @@ -194,6 +198,14 @@ export class QueryServerConfigListener extends ConfigListener implements QuerySe
return NUMBER_OF_THREADS_SETTING.getValue<number>();
}

public get saveCache(): boolean {
return SAVE_CACHE_SETTING.getValue<boolean>();
}

public get cacheSize(): number {
return CACHE_SIZE_SETTING.getValue<number | null>() || 0;
}

/** Gets the configured query timeout, in seconds. This looks up the setting at the time of access. */
public get timeoutSecs(): number {
return TIMEOUT_SETTING.getValue<number | null>() || 0;
Expand Down Expand Up @@ -236,7 +248,6 @@ export class CliConfigListener extends ConfigListener implements CliConfig {
return NUMBER_OF_TEST_THREADS_SETTING.getValue();
}


public get numberThreads(): number {
return NUMBER_OF_THREADS_SETTING.getValue<number>();
}
Expand Down
9 changes: 9 additions & 0 deletions extensions/ql-vscode/src/queryserver-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,15 @@ export class QueryServerClient extends DisposableObject {
const ramArgs = await this.cliServer.resolveRam(this.config.queryMemoryMb, progressReporter);
const args = ['--threads', this.config.numThreads.toString()].concat(ramArgs);

if (this.config.saveCache) {
args.push('--save-cache');
}

if (this.config.cacheSize > 0) {
args.push('--max-disk-cache');
args.push(this.config.cacheSize.toString());
}

if (await this.supportsDatabaseRegistration()) {
args.push('--require-db-registration');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ describe('config listeners', function() {
name: 'codeQL.runningQueries.numberOfThreads',
property: 'numThreads',
values: [0, 1]
}, {
name: 'codeQL.runningQueries.saveCache',
property: 'saveCache',
values: [false, true]
}, {
name: 'codeQL.runningQueries.cacheSize',
property: 'cacheSize',
values: [0, 1]
}, {
name: 'codeQL.runningQueries.memory',
property: 'queryMemoryMb',
Expand Down