Skip to content

Commit bd7b54a

Browse files
committed
perf: install LLVM and GCC in parallel
1 parent 96bc4cd commit bd7b54a

File tree

6 files changed

+35
-23
lines changed

6 files changed

+35
-23
lines changed

dist/node12/setup_cpp.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/node12/setup_cpp.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/node16/setup_cpp.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/node16/setup_cpp.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/llvm/llvm.ts

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import { existsSync } from "fs"
2020
import ciDetect from "@npmcli/ci-detect"
2121
import { setupGcc } from "../gcc/gcc"
2222
import { getVersion } from "../versions/versions"
23-
import { isArch } from "../utils/env/isArch"
2423
import { isUbuntu } from "../utils/env/isUbuntu"
2524

2625
//================================================
@@ -291,31 +290,45 @@ async function getLLVMPackageInfo(version: string, platform: NodeJS.Platform, _a
291290
}
292291

293292
export async function setupLLVM(version: string, setupDir: string, arch: string): Promise<InstallationInfo> {
294-
const installationInfo = await _setupLLVM(version, setupDir, arch)
293+
const installationInfo = await setupLLVMWithoutActivation(version, setupDir, arch)
295294
await activateLLVM(installationInfo.installDir ?? setupDir, version)
296295
return installationInfo
297296
}
298297

299-
let didInit = false
300-
async function _setupLLVM(version: string, setupDir: string, arch: string) {
301-
const installationInfo = await setupBin("llvm", version, getLLVMPackageInfo, setupDir, arch)
302-
if (!didInit) {
303-
if (process.platform === "linux") {
304-
// install llvm build dependencies
305-
await setupGcc(getVersion("gcc", undefined), "", arch) // using llvm requires ld, an up to date libstdc++, etc. So, install gcc first
306-
if (isArch()) {
307-
// setupPacmanPack("ncurses")
308-
// TODO: install libtinfo ?
309-
} else if (isUbuntu()) {
310-
await setupAptPack("libtinfo-dev")
311-
}
312-
}
298+
let installedDeps = false
299+
300+
async function setupLLVMWithoutActivation(version: string, setupDir: string, arch: string) {
301+
const installationInfoPromise = setupBin("llvm", version, getLLVMPackageInfo, setupDir, arch)
302+
303+
let depsPromise: Promise<void>
304+
if (!installedDeps) {
305+
depsPromise = setupLLVMDeps(arch)
313306
// eslint-disable-next-line require-atomic-updates
314-
didInit = true
307+
installedDeps = true
308+
} else {
309+
depsPromise = Promise.resolve()
315310
}
311+
312+
// install LLVM and its dependencies in parallel
313+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
314+
const [installationInfo, _] = await Promise.all([installationInfoPromise, depsPromise])
315+
316316
return installationInfo
317317
}
318318

319+
async function setupLLVMDeps(arch: string) {
320+
if (process.platform === "linux") {
321+
// install llvm build dependencies
322+
await setupGcc(getVersion("gcc", undefined), "", arch) // using llvm requires ld, an up to date libstdc++, etc. So, install gcc first
323+
324+
if (isUbuntu()) {
325+
await setupAptPack("libtinfo-dev")
326+
}
327+
// TODO: install libtinfo on other distros
328+
// setupPacmanPack("ncurses")
329+
}
330+
}
331+
319332
export async function activateLLVM(directory: string, versionGiven: string) {
320333
const version = semverCoerceIfInvalid(versionGiven)
321334

@@ -378,7 +391,7 @@ export function setupClangTools(version: string, setupDir: string, arch: string)
378391
if (ciDetect() === "github-actions") {
379392
addLLVMLoggingMatcher()
380393
}
381-
return _setupLLVM(version, setupDir, arch)
394+
return setupLLVMWithoutActivation(version, setupDir, arch)
382395
}
383396

384397
function addLLVMLoggingMatcher() {

src/python/python.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import { hasDnf } from "../utils/env/hasDnf"
1313
import { setupDnfPack } from "../utils/setup/setupDnfPack"
1414
import { isUbuntu } from "../utils/env/isUbuntu"
1515
import { getExecOutput } from "@actions/exec"
16-
import { existsSync } from "fs"
1716
import { isBinUptoDate } from "../utils/setup/version"
1817
import { getVersion } from "../versions/versions"
1918
import assert from "assert"

0 commit comments

Comments
 (0)