End tracing early in autobuild Action for improved performance and reliability
This lets us achieve some performance and reliability improvements for workflows that run autobuild directly without specifying a build mode.
This commit is contained in:
parent
7a6352f8e6
commit
5ac5c91bc1
9 changed files with 46 additions and 18 deletions
|
|
@ -402,13 +402,10 @@ export async function runFinalize(
|
|||
logger,
|
||||
);
|
||||
|
||||
// WARNING: This does not _really_ end tracing, as the tracer will restore its
|
||||
// critical environment variables and it'll still be active for all processes
|
||||
// launched from this build step.
|
||||
// However, it will stop tracing for all steps past the codeql-action/analyze
|
||||
// step.
|
||||
// Delete variables as specified by the end-tracing script
|
||||
await endTracingForCluster(codeql, config, features);
|
||||
// If we didn't already end tracing in the autobuild Action, end it now.
|
||||
if (process.env[EnvVar.AUTOBUILD_DID_COMPLETE_SUCCESSFULLY] !== "true") {
|
||||
await endTracingForCluster(codeql, config, logger, features);
|
||||
}
|
||||
return timings;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import {
|
|||
sendStatusReport,
|
||||
ActionName,
|
||||
} from "./status-report";
|
||||
import { endTracingForCluster } from "./tracer-config";
|
||||
import {
|
||||
checkActionVersion,
|
||||
checkDiskUsage,
|
||||
|
|
@ -125,6 +126,10 @@ async function run() {
|
|||
await runAutobuild(config, language, features, logger);
|
||||
}
|
||||
}
|
||||
|
||||
// End tracing early to avoid tracing analyze. This improves the performance and reliability of
|
||||
// the analyze step.
|
||||
await endTracingForCluster(codeql, config, logger, features);
|
||||
} catch (unwrappedError) {
|
||||
const error = wrapError(unwrappedError);
|
||||
core.setFailed(
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import { type CodeQL } from "./codeql";
|
|||
import { type Config } from "./config-utils";
|
||||
import { Feature, FeatureEnablement } from "./feature-flags";
|
||||
import { isTracedLanguage } from "./languages";
|
||||
import { Logger } from "./logging";
|
||||
import { ToolsFeature } from "./tools-features";
|
||||
import { BuildMode } from "./util";
|
||||
|
||||
|
|
@ -28,13 +29,27 @@ export async function shouldEnableIndirectTracing(
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete variables as specified by the end-tracing script
|
||||
*
|
||||
* WARNING: This does not _really_ end tracing, as the tracer will restore its
|
||||
* critical environment variables and it'll still be active for all processes
|
||||
* launched from this build step.
|
||||
*
|
||||
* However, it will stop tracing for all steps past the current build step.
|
||||
*/
|
||||
export async function endTracingForCluster(
|
||||
codeql: CodeQL,
|
||||
config: Config,
|
||||
logger: Logger,
|
||||
features: FeatureEnablement,
|
||||
): Promise<void> {
|
||||
if (!(await shouldEnableIndirectTracing(codeql, config, features))) return;
|
||||
|
||||
logger.info(
|
||||
"Unsetting build tracing environment variables. Subsequent steps of this job will not be traced.",
|
||||
);
|
||||
|
||||
const envVariablesFile = path.resolve(
|
||||
config.dbLocation,
|
||||
"temp/tracingEnvironment/end-tracing.json",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue