-
Notifications
You must be signed in to change notification settings - Fork 39
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
Seems quick! where's the cache? #14
Comments
What do you mean by damage file? Saving dependencies/whole bun into cache? |
When a file is damaged (changed), the cache should be dropped and refreshed. setup-node calls it EDIT2: Yes please. If there was caching for the built dependencies subsequent runs would be even faster(?). |
It might be possible to use github action's Alternatively shouldn't we just always cache the |
Yeah, that seems reasonable (until there's a better option).
You could, but it doesn't align to the other node projects. If there's no problem with it in bun that's fine, but the other products expressly look at this. |
I haven't had a chance to use bun much yet, but from what I can see from the docs, it supposedly always downloads packages to that folder, then uses hardlinks to add the packages to the If that's the case, then that's the only folder that needs to be cached. You could cache it with the same key every time, or use that same |
We haven't implemented dependency caching yet, because early testing showed |
I tested the solution mentioned above with:
It reduces the |
For me, this cache config adds 2 seconds to restore the cache and then drops my bun install time from 6-10s to <2s. Of course sometimes the cache restore takes longer due to network variability, but that variability impacts install time too if fetching all deps every time. Seems worthwhile overall to put something like this in by default (exact ideal key config is up for debate). - uses: actions/cache@v4
with:
path: ~/.bun/install/cache
key: ${{ runner.os }}-${{ matrix.bun }}-bun-${{ hashFiles('**/bun.lockb') }}
restore-keys: |
${{ runner.os }}-${{ matrix.bun }}-bun- |
@bgentry but what about the time to save the cache? In my GitLab CI it took 2 min to save the cache: (35s to restore cache, 2s to install). On a run that the .lock file was changed (so, changed cache key and then no cache), it took 17s to install the packages and 1m20s to save the cache. I use https://www.sonatype.com/products/sonatype-nexus-repository, so that might already remove the need to cache again the deps. |
1m20s sounds like you either have an enormous set of deps to cache, or a very slow transfer speed. With GitHub Actions my cache save time was generally under 10 seconds. |
I'm a bit confused, can someone help me out. This seems to be so suspiciously fast that it seems impossible. I just refactored a workflow. The steps used to look like this (bunch of details omitted for brevity): Single cached install step, then multiple parallel jobs after thatinstall-cache:
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- run: yarn install
- run: npx playwright install
- uses: actions/cache/save@v4
test-types:
needs: install-cache
steps:
- uses: actions/checkout@v4
- uses: actions/cache/restore@v4
- run: yarn test:types
test-unit:
needs: install-cache
steps:
- uses: actions/checkout@v4
- uses: actions/cache/restore@v4
- run: yarn test:unit
test-e2e:
needs: install-cache
steps:
- uses: actions/checkout@v4
- uses: actions/cache/restore@v4
- run: yarn test:e2e While experimenting with transitioning our stack from Node/Yarn to Bun, I updated this to just look like this: All jobs start right away in parallel, install step just duplicated in every jobtest-types:
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
- run: bun install
- run: bun run test:types
test-unit:
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
- run: bun install
- run: bun run test:unit
test-e2e:
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
- run: bun install
- run: bunx playwright install
- run: bun run test:e2e And... Bun installs the packages in less than a second? How is that possible when we have ~50 dependencies? Surely just the network download of the packages alone must take more than a second? Is there some kind of edge computing going on here where Actions can download the packages extra fast? Or is there a hidden cache somewhere that I'm unable to see? Our Actions cache page seems to be empty, and I believe even if some third-party action (e.g. More details about how just ditching @actions/cache all-together saved me timeRegarding the fact that my change doesn't cache playwright anymore... simply saving (~10s) and restoring (~10s) our Here are some comparison of run times between the different caching/installation approaches:
|
I can't understand its functionality, and also it doesn't look really efficient with bun (oven-sh/setup-bun#14 (comment))
I can't understand its functionality, and also it doesn't look really efficient with bun (oven-sh/setup-bun#14 (comment))
Does anyone have insight into why the results here seem to vary so much? Some reports of cache being much faster, some reports of cache being the same, and some reports (myself included) showing cache taking longer. No cache: 21s to download and install GitHub Action with no cache
name: Bun Install Benchmark
on:
push:
branches:
- main
workflow_dispatch:
jobs:
dependencies:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Bun
uses: oven-sh/setup-bun@v2
- name: Install Dependencies
run: bun i GitHub Action with cache
name: Bun Install (With Cache) Benchmark
on:
push:
branches:
- main
workflow_dispatch:
jobs:
dependencies:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Cache Bun dependencies
uses: actions/cache@v4
with:
path: ~/.bun/install/cache
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }}
restore-keys: |
${{ runner.os }}-bun-
- name: Setup Bun
uses: oven-sh/setup-bun@v2
- name: Install Dependencies
run: bun i |
Title is a bit tongue in cheek.
It doesn't look like there's a way to set a damage file or anything for purposes of a cache in the action.
This is normally configured in the actions/setup-node action on GH actions.
It doesn't look like bun has that, which is a bit disappointing because it feels like there might be an even deeper win here if that was available.
The text was updated successfully, but these errors were encountered: