-
Notifications
You must be signed in to change notification settings - Fork 583
Fix slow cache restore on Windows #515
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
base: main
Are you sure you want to change the base?
Conversation
Use D drive for faster cache restore Signed-off-by: Anton Troshin <anton@diagrid.io>
Signed-off-by: Anton Troshin <anton@diagrid.io>
Signed-off-by: Anton Troshin <anton@diagrid.io>
Signed-off-by: Anton Troshin <anton@diagrid.io>
Signed-off-by: Anton Troshin <anton@diagrid.io>
Signed-off-by: Anton Troshin <anton@diagrid.io>
Signed-off-by: Anton Troshin <anton@diagrid.io>
Signed-off-by: Anton Troshin <anton@diagrid.io>
Signed-off-by: Anton Troshin <anton@diagrid.io>
…rs for Windows Signed-off-by: Anton Troshin <anton@diagrid.io>
Signed-off-by: Anton Troshin <anton@diagrid.io>
@antontroshin When do you plan to merge it? |
@y-bruin Unfortunately, I cannot merge, as this is up to repo maintainers, once the PR is reviewed and approved. |
For anyone else also waiting for this to get some attention:
Setting GOTMPDIR to D: was necessary to cut down the time it took to go install from cache. |
add validation for GOCACHE, GOMODCACHE, and GOTMPDIR on Windows Signed-off-by: Anton Troshin <anton@diagrid.io>
Hi @HarithaVattikuti, @priya-kinthali, @aparnajyothi-y, @priyagupta108 |
Hello @antontroshin, Thank you for submitting this pull request. We will review and get back to you once we have some feedback on this :) |
Closing and Reopening the PR to trigger the CI checks |
Hi @antontroshin, Firstly, Thank you for your contribution and the code changes to address the slow cache restore issue on Windows. Your PR is successfully minimizing cache timing on GitHub-hosted Windows runners. However, We noticed that there is a test case failing as per the checks and the changes in this PR are currently not working on self-hosted runners when checked in both cases (With and Without D Drive)—they are causing failures in those environments. The screenshot of the failed workflow when ran with self hosted runner having D drive is given as of below. Could you please update the PR to fix the failing test case and ensure that the changes do not negatively affect self-hosted runners, while still resolving the cache timing issue for GitHub-hosted Windows runners? |
Signed-off-by: Anton Troshin <18515134+antontroshin@users.noreply.github.com>
Hi @lmvysakh As for lack of drive "D:", I've added this check to skip the customization of the Go cache paths because the only safe assumption we can make in this case is that drive "C:" (default path locations) is the only drive that exist. It may be a good idea to add this limitation for Windows machines to the README, with instructions on how to customize these paths by setting ENV variables manually, as @lmb commented above. |
Hi @antontroshin, Thank you for your contribution and for working to improve cache restore performance on Windows runners! We wanted to highlight that, as per the update, the D drive will no longer be accessible on GitHub-hosted Windows Server 2025 runners starting from July 14, 2025. Most Windows runners already do not have a D drive available, and this change will make it unavailable across all relevant runners for performance and startup reasons. Since the current implementation in this PR achieves its speed improvement primarily by utilising the D drive, it might not work reliably for the majority of users and will break entirely once the D drive is removed from the images. Would you be open to exploring alternative approaches that do not rely on the D drive? This will help ensure broader compatibility and long-term support for all users of the action. Thank you again for your efforts and for considering this feedback! |
Hi @lmvysakh, export const setWindowsCacheDirectories = async () => {
if (os.platform() !== 'win32') return;
if (!fs.existsSync('D:')) return;
...
} If there's no D drive, the function will exit early, and env variables will be kept as-is, pointing to default locations, which is drive C, and thus preserving original behavior. Please let me know if this answers the concerns. Of course, I'm open to feedback if anything needs to be changed or improved. One last thing, would you be so kind as to please rerun the one failed action Thanks. |
Description:
The issue with running setup-go and restoring relatively big cache files, causes the cache restore process to be very slow on Github Action Windows runners.
Similar to the change that was made in version v5.0.0 (PR #411), I've made a change to override the default
GOCACHE
andGOMODCACHE
variables on Windows runners to be using drive D.On average, restoring ~1.7Gb cache on Windows pipelines took about 13-15 minutes to extract.
With this change, the extraction time was reduced to ~1m.
Restore cache logs before the change:
Restore cache logs after the change:
Solution:
At first, I tried to implement a solution similar to #411 by using symlink, however, during testing, it was clear that the
GOCACHE
andGOMODCACHE
directories were created early by the tooling, which did not present an easy way to create symlinks without deleting the already in-use directories and introducing bigger code changes.The solution to override the path for env vars as early as possible only on Windows runners is easier.
This PR adds the code to make this change by default for Windows runners, this "workaround" is possible to use via the Github Action code itself, by manually overriding the env vars.
Preferably, this change would be accepted and merged (after review of course), so users can enjoy this improvement by default without manually modifying each and every Github action.
Related issue:
Numerous related issues were raised regarding this issue, some improvements were made to address it.
Check list: