Skip to content

Commit 2338b17

Browse files
authored
Merge pull request #567 from dennisameling/use-d-drive-if-available
Use fast D: drive if available
2 parents e8f2204 + 6f5c3c0 commit 2338b17

File tree

3 files changed

+42
-5
lines changed

3 files changed

+42
-5
lines changed

dist/index.js

+18-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

main.ts

+23-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,24 @@ import * as fs from 'fs'
1313
const flavor = core.getInput('flavor')
1414
const architecture = core.getInput('architecture')
1515

16+
/**
17+
* Some Azure VM types have a temporary disk which is local to the VM and therefore provides
18+
* _much_ faster disk IO than the OS Disk (or any other attached disk).
19+
*
20+
* Hosted GitHub Actions runners also leverage this disk and do their work in D:/a/_work, so let's
21+
* use it too if we can. It leads to a ~25% speed increase when doing heavy IO operations.
22+
*
23+
* https://learn.microsoft.com/en-us/azure/virtual-machines/managed-disks-overview#temporary-disk
24+
*/
25+
function getDriveLetterPrefix(): string {
26+
if (fs.existsSync('D:/')) {
27+
core.info('Found a fast, temporary disk on this VM (D:/). Will use that.')
28+
return 'D:/'
29+
}
30+
31+
return 'C:/'
32+
}
33+
1634
async function run(): Promise<void> {
1735
try {
1836
if (process.platform !== 'win32') {
@@ -37,7 +55,8 @@ async function run(): Promise<void> {
3755
architecture,
3856
githubToken
3957
)
40-
const outputDirectory = core.getInput('path') || `C:/${artifactName}`
58+
const outputDirectory =
59+
core.getInput('path') || `${getDriveLetterPrefix()}${artifactName}`
4160
let useCache: boolean
4261
switch (core.getInput('cache')) {
4362
case 'true':
@@ -153,7 +172,9 @@ function cleanup(): void {
153172

154173
const outputDirectory =
155174
core.getInput('path') ||
156-
`C:/${getArtifactMetadata(flavor, architecture).artifactName}`
175+
`${getDriveLetterPrefix()}${
176+
getArtifactMetadata(flavor, architecture).artifactName
177+
}`
157178

158179
/**
159180
* Shelling out to `rm -rf` is more than twice as fast as Node's `fs.rmSync` method.

0 commit comments

Comments
 (0)