cache: Cache restoration is orders of magnitude slower on Windows compared to Linux.
We are using this action to cache Conan packages.
Our current cached is ~300 MB on both Linux (ubuntu-20.04) and Windows (windows-2019).
Sadly, where the cache step routinely takes ~10 seconds on Linux, it oftentimes takes ~5 minutes on Windows.
This makes iterations frustrating, as the rest of the workflow takes about 2 minutes to complete, we get a global x3 time penalty because of this.
As far as I can tell, the archive retrieval time is comparable, it really is the cache un-archiving which seems to take very long on Windows.
Our latest run below for illustration purposes.
Linux:

Windows:

About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 25
- Comments: 31 (4 by maintainers)
Commits related to this issue
- Run steps that must be run only once on ubuntu-latest Ubuntu is overall faster than macOS and Windows. Also this [recent issue][1] seems macOS specific. See also [Restoring cache on MacOS is extreme... — committed to serilog-contrib/serilog-formatting-log4net by 0xced 4 years ago
- Use gnu tar on windows CI See https://github.com/actions/cache/issues/752 — committed to watchexec/watchexec by passcod 4 years ago
- Add tar to Windows CI path per actions/cache#752 — committed to bufbuild/buf by jchadwick-buf 3 years ago
- VisualStudioHelpers.ps1 stop enabling 8.3 filename creation The bug that prompted enabling 8.3 filename creation was fixed 5 years ago, see https://github.com/xamarin/xamarin-android/issues/3407: >... — committed to actions/runner-images by congyiwu 3 years ago
- VisualStudioHelpers.ps1 stop enabling 8.3 filename creation (#9862) The bug that prompted enabling 8.3 filename creation was fixed 5 years ago, see https://github.com/xamarin/xamarin-android/issues/3... — committed to actions/runner-images by congyiwu 3 years ago
- ci: speed up windows build (#3474) Windows warm cache run reduced from 3 mins to 2 mins 20 seconds. Unsung heros of the internet, who led me here to speed up window's slowness: * `https://github... — committed to oxc-project/oxc by Boshen 2 years ago
- VisualStudioHelpers.ps1 stop enabling 8.3 filename creation (#9862) The bug that prompted enabling 8.3 filename creation was fixed 5 years ago, see https://github.com/xamarin/xamarin-android/issues/3... — committed to etn-utilities/devsecops-gha-runner-images by congyiwu 3 years ago
I just spent 3 days trying to find a workaround for this, so I hope this helps someone…
Background:
We use Bazel, and the local Bazel cache, although it is not necessarily big (~200 MB in our case), it contains a ton of small files (including symlinks). For us, it took ~19 Minutes to untar those 200 MB on Windows 😖
Failed attempts:
Based on this Windows issue (also linked above), my initial attempts were related to the Windows Defender:
➜ However, I found out that all relevant features are already disabled and the entire
D:/drive (where the cache is extracted) is already excluded by default in the Github runners.➜ However, that requires a reboot. So, that’s only viable on a self-hosted runner.
BTW: The cache action already uses the
tar.exefrom Git Bash (C:\Program Files\Git\usr\bin\tar.exe), so this workaround (suggested by @lvpx >1 year ago) makes no difference anymore.Our current workaround:
The underlaying issue is the large amount of files that need to be extracted, so let’s reduce the cache to a single file: ➜ Let’s put the cache in a Virtual Hard Disk!
So this is our solution:
I know… it’s long and ugly, but it works: Extracting the cache only takes 7 seconds and mounting the VHDX only takes 19 seconds! 🎉 This means that we reduced the cache restoration time by a factor of 44 🤓
This is based on Example 3 of the Mount-VHD docs and Example 5 of the New-VHD docs. I’m by no means proficient in powershell scripting, so there might be room for improvement…
A few details about the solution:
E:/in the Github runners. However, this is not necessarily deterministic. I tried assigning a specific Drive Letter, but there are two issues with that: 1. the drive could be occupied and 2. theMount-VHDcommand doesn’t support that (only theNew-Partitioncommand does).So, we store the path of the drive in a new
CACHE_DRIVEenvironment variable that we can use in later steps.always()or!cancelled()in theDismount VHDXstep, because if something fails, the cache will be disregarded anyways. So, we don’t care if the volume gets dismounted or not 🤷@paco-sevilla This is awesome. I found myself recently needing to do this across multiple jobs and was surprised there were no Github Actions that could do this. I ended up creating one since I thought others might benefit samypr100/setup-dev-drive.
@Safihre we are not part of GitHub anymore unfortunately. Hopefully someone will be pick these pending issues and respond.
Thanks @paco-sevilla. It’s just a bit crazy we have to resort to these kind of solutions instead of a proper solution from GitHub. This has been going on for ages. And it can’t just be the free users (like me) that experience this, also the corporate customers that actually pay for each Actions-minute must experience this and need reduction.
Looks like this has been going on for awhile… See also #442 and #529. Hopefully @bishal-pdMSFT can make some improvements here? Maybe just provide an optional parameter to the action that would tell it to use
.zip(or another format) instead of.tgzon Windows? 7-Zip is pre-installed on the virtual environments.@pdotl since #984 was narrowed down to cross-os (ref) should this issue be reopened?
Thank you for your reponse!
(If the issue is with the specific un-archiving utility, maybe there is an alternative that the action could use on Windows to get better performances?)
Thats unfortunate to hear, the action does give you the flexibility to change the format to NTFS if desired.
Awesome job @samypr100 - I’ll have to try it out! - I was experimenting here with NTFS and tried ReFS - https://github.com/malkia/opentelemetry-cpp/blob/main/.github/workflows/otel_sdk.yml#L28 - though the VHDX gets to be much bigger (in size, granted mostly zeroes). Wonder what else I can do there.
@samypr100 Your Github Action is awesome! And the examples are super useful! Thanks for creating it and also for the acknowledgements in the README 🙂
I think that, if something similar would be implemented in this Action and the documentation was updated, this issue could finally be closed (after more than 2 years)…
+1 Attempting to cache on Windows proves to be a significant waste of time; I spent hours on it. At the very least, the official documentation should be updated to document this “known issue.”
@paco-sevilla - Thank you so much!!! I’ve been just experiencing this issue - where 25 mins to decompress the bazel cache (granted It’s probably caching more than needs to). Thank you! Thank you! Thank you!
@bethanyj28 seems to be releasing latest version. They might help get this on someone’s radar.