Use feature flag to enable evaluator intra-layer parallelism

This commit is contained in:
Nick Rolfe 2023-07-31 09:44:35 +01:00
parent 81ae676e79
commit bc068d74aa
9 changed files with 33 additions and 6 deletions

4
lib/analyze.js generated
View file

@ -285,7 +285,7 @@ async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag,
fs.writeFileSync(querySuitePath, querySuiteContents); fs.writeFileSync(querySuitePath, querySuiteContents);
logger.debug(`Query suite file for ${language}-${type}...\n${querySuiteContents}`); logger.debug(`Query suite file for ${language}-${type}...\n${querySuiteContents}`);
} }
await codeql.databaseRunQueries(databasePath, searchPath, querySuitePath, queryFlags, optimizeForLastQueryRun); await codeql.databaseRunQueries(databasePath, searchPath, querySuitePath, queryFlags, optimizeForLastQueryRun, features);
logger.debug(`BQRS results produced for ${language} (queries: ${type})"`); logger.debug(`BQRS results produced for ${language} (queries: ${type})"`);
return querySuitePath; return querySuitePath;
} }
@ -299,7 +299,7 @@ async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag,
const querySuitePath = `${databasePath}-queries-${type}.qls`; const querySuitePath = `${databasePath}-queries-${type}.qls`;
fs.writeFileSync(querySuitePath, yaml.dump(querySuite)); fs.writeFileSync(querySuitePath, yaml.dump(querySuite));
logger.debug(`BQRS results produced for ${language} (queries: ${type})"`); logger.debug(`BQRS results produced for ${language} (queries: ${type})"`);
await codeql.databaseRunQueries(databasePath, undefined, querySuitePath, queryFlags, optimizeForLastQueryRun); await codeql.databaseRunQueries(databasePath, undefined, querySuitePath, queryFlags, optimizeForLastQueryRun, features);
return querySuitePath; return querySuitePath;
} }
} }

File diff suppressed because one or more lines are too long

5
lib/codeql.js generated
View file

@ -419,7 +419,7 @@ async function getCodeQLForCmd(cmd, checkVersion) {
throw new Error(`Unexpected output from codeql resolve build-environment: ${e} in\n${output}`); throw new Error(`Unexpected output from codeql resolve build-environment: ${e} in\n${output}`);
} }
}, },
async databaseRunQueries(databasePath, extraSearchPath, querySuitePath, flags, optimizeForLastQueryRun) { async databaseRunQueries(databasePath, extraSearchPath, querySuitePath, flags, optimizeForLastQueryRun, features) {
const codeqlArgs = [ const codeqlArgs = [
"database", "database",
"run-queries", "run-queries",
@ -439,6 +439,9 @@ async function getCodeQLForCmd(cmd, checkVersion) {
if (querySuitePath) { if (querySuitePath) {
codeqlArgs.push(querySuitePath); codeqlArgs.push(querySuitePath);
} }
if (await features.getValue(feature_flags_1.Feature.EvaluatorIntraLayerParallelismEnabled, this)) {
codeqlArgs.push("--intra-layer-parallelism");
}
await runTool(cmd, codeqlArgs); await runTool(cmd, codeqlArgs);
}, },
async databaseInterpretResults(databasePath, querySuitePaths, sarifFile, addSnippetsFlag, threadsFlag, verbosityFlag, automationDetailsId, config, features, logger) { async databaseInterpretResults(databasePath, querySuitePaths, sarifFile, addSnippetsFlag, threadsFlag, verbosityFlag, automationDetailsId, config, features, logger) {

File diff suppressed because one or more lines are too long

6
lib/feature-flags.js generated
View file

@ -50,6 +50,7 @@ var Feature;
Feature["CliConfigFileEnabled"] = "cli_config_file_enabled"; Feature["CliConfigFileEnabled"] = "cli_config_file_enabled";
Feature["DisableKotlinAnalysisEnabled"] = "disable_kotlin_analysis_enabled"; Feature["DisableKotlinAnalysisEnabled"] = "disable_kotlin_analysis_enabled";
Feature["DisablePythonDependencyInstallationEnabled"] = "disable_python_dependency_installation_enabled"; Feature["DisablePythonDependencyInstallationEnabled"] = "disable_python_dependency_installation_enabled";
Feature["EvaluatorIntraLayerParallelismEnabled"] = "evaluator_intra_layer_parallelism_enabled";
Feature["ExportDiagnosticsEnabled"] = "export_diagnostics_enabled"; Feature["ExportDiagnosticsEnabled"] = "export_diagnostics_enabled";
Feature["MlPoweredQueriesEnabled"] = "ml_powered_queries_enabled"; Feature["MlPoweredQueriesEnabled"] = "ml_powered_queries_enabled";
Feature["NewAnalysisSummaryEnabled"] = "new_analysis_summary_enabled"; Feature["NewAnalysisSummaryEnabled"] = "new_analysis_summary_enabled";
@ -68,6 +69,11 @@ exports.featureConfig = {
minimumVersion: "2.11.6", minimumVersion: "2.11.6",
defaultValue: true, defaultValue: true,
}, },
[Feature.EvaluatorIntraLayerParallelismEnabled]: {
envVar: "CODEQL_EVALUATOR_INTRA_LAYER_PARALLELISM",
minimumVersion: "2.14.0",
defaultValue: false,
},
[Feature.ExportDiagnosticsEnabled]: { [Feature.ExportDiagnosticsEnabled]: {
envVar: "CODEQL_ACTION_EXPORT_DIAGNOSTICS", envVar: "CODEQL_ACTION_EXPORT_DIAGNOSTICS",
minimumVersion: "2.12.4", minimumVersion: "2.12.4",

File diff suppressed because one or more lines are too long

View file

@ -487,6 +487,7 @@ export async function runQueries(
querySuitePath, querySuitePath,
queryFlags, queryFlags,
optimizeForLastQueryRun, optimizeForLastQueryRun,
features,
); );
logger.debug(`BQRS results produced for ${language} (queries: ${type})"`); logger.debug(`BQRS results produced for ${language} (queries: ${type})"`);
@ -521,6 +522,7 @@ export async function runQueries(
querySuitePath, querySuitePath,
queryFlags, queryFlags,
optimizeForLastQueryRun, optimizeForLastQueryRun,
features,
); );
return querySuitePath; return querySuitePath;

View file

@ -160,6 +160,7 @@ export interface CodeQL {
querySuitePath: string | undefined, querySuitePath: string | undefined,
flags: string[], flags: string[],
optimizeForLastQueryRun: boolean, optimizeForLastQueryRun: boolean,
features: FeatureEnablement,
): Promise<void>; ): Promise<void>;
/** /**
* Run 'codeql database interpret-results'. * Run 'codeql database interpret-results'.
@ -756,6 +757,7 @@ export async function getCodeQLForCmd(
querySuitePath: string | undefined, querySuitePath: string | undefined,
flags: string[], flags: string[],
optimizeForLastQueryRun: boolean, optimizeForLastQueryRun: boolean,
features: FeatureEnablement,
): Promise<void> { ): Promise<void> {
const codeqlArgs = [ const codeqlArgs = [
"database", "database",
@ -778,6 +780,14 @@ export async function getCodeQLForCmd(
if (querySuitePath) { if (querySuitePath) {
codeqlArgs.push(querySuitePath); codeqlArgs.push(querySuitePath);
} }
if (
await features.getValue(
Feature.EvaluatorIntraLayerParallelismEnabled,
this,
)
) {
codeqlArgs.push("--intra-layer-parallelism");
}
await runTool(cmd, codeqlArgs); await runTool(cmd, codeqlArgs);
}, },
async databaseInterpretResults( async databaseInterpretResults(

View file

@ -46,6 +46,7 @@ export enum Feature {
CliConfigFileEnabled = "cli_config_file_enabled", CliConfigFileEnabled = "cli_config_file_enabled",
DisableKotlinAnalysisEnabled = "disable_kotlin_analysis_enabled", DisableKotlinAnalysisEnabled = "disable_kotlin_analysis_enabled",
DisablePythonDependencyInstallationEnabled = "disable_python_dependency_installation_enabled", DisablePythonDependencyInstallationEnabled = "disable_python_dependency_installation_enabled",
EvaluatorIntraLayerParallelismEnabled = "evaluator_intra_layer_parallelism_enabled",
ExportDiagnosticsEnabled = "export_diagnostics_enabled", ExportDiagnosticsEnabled = "export_diagnostics_enabled",
MlPoweredQueriesEnabled = "ml_powered_queries_enabled", MlPoweredQueriesEnabled = "ml_powered_queries_enabled",
NewAnalysisSummaryEnabled = "new_analysis_summary_enabled", NewAnalysisSummaryEnabled = "new_analysis_summary_enabled",
@ -68,6 +69,11 @@ export const featureConfig: Record<
minimumVersion: "2.11.6", minimumVersion: "2.11.6",
defaultValue: true, defaultValue: true,
}, },
[Feature.EvaluatorIntraLayerParallelismEnabled]: {
envVar: "CODEQL_EVALUATOR_INTRA_LAYER_PARALLELISM",
minimumVersion: "2.14.0",
defaultValue: false,
},
[Feature.ExportDiagnosticsEnabled]: { [Feature.ExportDiagnosticsEnabled]: {
envVar: "CODEQL_ACTION_EXPORT_DIAGNOSTICS", envVar: "CODEQL_ACTION_EXPORT_DIAGNOSTICS",
minimumVersion: "2.12.4", minimumVersion: "2.12.4",