Skip to content

Use fast D: drive if available #567

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 2, 2023

Conversation

dennisameling
Copy link
Contributor

Some Azure VM types have a temporary disk which is local to the VM and therefore provides much faster disk IO than the OS Disk (or any other attached disk).

Hosted GitHub Actions runners also leverage this disk and do their work in D:/a/_work, so let's use it too if we can. It leads to a ~25% speed increase when doing heavy IO operations.

Ref: https://learn.microsoft.com/en-us/azure/virtual-machines/managed-disks-overview#temporary-disk

@dennisameling dennisameling requested a review from dscho as a code owner December 28, 2022 21:34
Comment on lines +16 to +33
/**
* Some Azure VM types have a temporary disk which is local to the VM and therefore provides
* _much_ faster disk IO than the OS Disk (or any other attached disk).
*
* Hosted GitHub Actions runners also leverage this disk and do their work in D:/a/_work, so let's
* use it too if we can. It leads to a ~25% speed increase when doing heavy IO operations.
*
* https://learn.microsoft.com/en-us/azure/virtual-machines/managed-disks-overview#temporary-disk
*/
function getDriveLetterPrefix(): string {
if (fs.existsSync('D:/')) {
core.info('Found a fast, temporary disk on this VM (D:/). Will use that.')
return 'D:/'
}

return 'C:/'
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also leverage the $RUNNER_TEMP environment variable which resolves to D:\a\_temp for example. It depends on the directory where the Actions Runner is installed (e.g. D:\a or C:\a), meaning that we wouldn't have to use our own logic for this. WDYT? Any concerns about long path issues or something? I think D:\a\_temp\git-sdk-64-full vs D:\git-sdk-64-full isn't too much of a difference.

From the docs:

The path to a temporary directory on the runner. This directory is emptied at the beginning and end of each job. Note that files will not be removed if the runner's user account does not have permission to delete them. For example, D:\a\_temp

That should also allow us to get rid of our custom cleanup logic 👀🔥

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My intuition is that using $RUNNER_TEMP could potentially cause problems, even inadvertent ones, because the TEMP part of the name suggests something ethereal, not-so-critical.

Long paths are not my concern here, either. But disk space is. I'd love to have the speed improvements, but we need to be sure that we're not accidentally running out of space. According to this documentation we have 14GB of SSD, which should be enough, even if the SDK weighs in with over 2GB.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just checked and it seems that there is still a bit over 12GB free, so we're good to go!

dennisameling and others added 2 commits January 2, 2023 21:10
Some Azure VM types have a temporary disk which is local to the VM and
therefore provides _much_ faster disk IO than the OS Disk (or any other
attached disk).

Hosted GitHub Actions runners also leverage this disk and do their work
in D:/a/_work, so let's use it too if we can. It leads to a ~25% speed
increase when doing heavy IO operations.

Ref: https://learn.microsoft.com/en-us/azure/virtual-machines/managed-disks-overview#temporary-disk
Ref:
https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources

Signed-off-by: Dennis Ameling <[email protected]>
Signed-off-by: Johannes Schindelin <[email protected]>
Signed-off-by: Johannes Schindelin <[email protected]>
@dscho dscho force-pushed the use-d-drive-if-available branch from 736882d to 6f5c3c0 Compare January 2, 2023 20:12
@dscho dscho merged commit 2338b17 into git-for-windows:main Jan 2, 2023
@dscho
Copy link
Member

dscho commented Jan 2, 2023

It's now available as v1.7.0 of this Action.

@dennisameling dennisameling deleted the use-d-drive-if-available branch January 2, 2023 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants