perf: overlap compiler identity and native driver discovery (#634)

This commit is contained in:
Chris Tate
2026-10-03 11:01:42 -05:00
committed by GitHub
parent 992e49159f
commit 2f5463ea52
3 changed files with 16 additions and 10 deletions
+13 -7
View File
@@ -708,9 +708,20 @@ async function compileTracked(
: null;
let earlyCacheOptions: EarlyExecutableCacheOptions | null = null;
if (outputKind === "exe") {
const implementation = await compilerImplementationIdentity();
const helperObjectRoute = opts.nativeProgramObject === true ||
(usesPrecompiledRuntimePack(opts, "llvm"));
// Package content and native driver discovery are independent inputs to
// the same cache key. Start both before waiting so edits do not pay their
// filesystem and subprocess latency serially.
const [implementation, nativeEnvironment] = await Promise.all([
compilerImplementationIdentity(),
helperObjectRoute
? executableLinkerEnvironmentFingerprint(
process.env,
nativeCodegenTarget()?.defaultLinker,
)
: executableNativeEnvironmentFingerprint(),
]);
earlyCacheOptions = {
entryPath,
outDir: opts.outDir,
@@ -737,12 +748,7 @@ async function compileTracked(
? resolvePlatformLinker(process.env, nativeCodegenTarget()?.defaultLinker)
: (process.env["SCRIPTC_CC"] ?? "clang"),
],
nativeEnvironment: helperObjectRoute
? await executableLinkerEnvironmentFingerprint(
process.env,
nativeCodegenTarget()?.defaultLinker,
)
: await executableNativeEnvironmentFingerprint(),
nativeEnvironment,
nodeVersion: process.version,
implementation: implementation.digest,
implementationDependencies: implementation.dependencies,
@@ -27,8 +27,8 @@ test("parallel fingerprinting preserves the v1 byte stream and dependency order
const files: [string, string][] = [
[join("a", "index.ts"), "export const value = 42;\n"],
["a.ts", ""],
...Array.from({ length: 40 }, (_, i): [string, string] => [
join("z", `file${String(i).padStart(2, "0")}.js`),
...Array.from({ length: 140 }, (_, i): [string, string] => [
join("z", `file${String(i).padStart(3, "0")}.js`),
`// ${i}\n${"\u03bb".repeat(i * 1000)}`,
]),
];
@@ -80,7 +80,7 @@ export async function compilerImplementationIdentity(
// trips on every application edit; reading the entire package at once
// would retain all its bytes and open an unbounded number of files.
const hash = createHash("sha256").update("scriptc-frontend-implementation-v1\0");
const batchSize = 16;
const batchSize = 64;
for (let start = 0; start < entries.length; start += batchSize) {
const batch = await Promise.all(entries.slice(start, start + batchSize).map(async (entry) => {
if (entry.directory !== undefined) return { ...entry, info: entry.directory, bytes: null };