Cache doesn't speed up the install much
See original GitHub issueIf this is not the correct place to ask this, please point me in the right direction.
I have the most basic cache step:
- name: Cache node_modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
…and it works as expected:
2020-10-02T14:33:01.7414870Z Received 26076859 of 26076859 (100.0%), 72.1 MBs/sec
2020-10-02T14:33:01.7417520Z Cache Size: ~25 MB (26076859 B)
2020-10-02T14:33:01.7454619Z [command]/bin/tar --use-compress-program zstd -d -xf /home/runner/work/_temp/086c9fc2-88ee-4881-bdaa-2a2c8f1015db/cache.tzst -P -C /home/runner/work/{{ censored }}
2020-10-02T14:33:01.8951789Z Cache restored from key: Linux-build-cache-node-modules-fd785df44b88bf30dd9aa1dbc1a05d8109a04b7556a7faaa30c5b6e8e0f6f3f1
…but the install still takes 11 seconds:
2020-10-02T14:33:14.0087247Z > core-js@3.6.5 postinstall /home/runner/work/{{ censored }}/node_modules/core-js
2020-10-02T14:33:14.0088330Z > node -e "try{require('./postinstall')}catch(e){}"
2020-10-02T14:33:14.0088750Z
2020-10-02T14:33:14.6836898Z npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/watchpack-chokidar2/node_modules/fsevents):
2020-10-02T14:33:14.6842797Z npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
2020-10-02T14:33:14.6977981Z npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_modules/fsevents):
2020-10-02T14:33:14.6979492Z npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
2020-10-02T14:33:14.6980325Z
2020-10-02T14:33:14.7006254Z added 821 packages from 472 contributors and audited 823 packages in 11.745s
2020-10-02T14:33:15.1212777Z
2020-10-02T14:33:15.1214296Z 32 packages are looking for funding
2020-10-02T14:33:15.1215209Z run `npm fund` for details
2020-10-02T14:33:15.1215783Z
2020-10-02T14:33:15.1218573Z found 0 vulnerabilities
For reference, the install without the cache step takes 14 seconds:
2020-10-02T14:31:24.4947005Z > core-js@3.6.5 postinstall /home/runner/work/{{ censored }}/node_modules/core-js
2020-10-02T14:31:24.4954346Z > node -e "try{require('./postinstall')}catch(e){}"
2020-10-02T14:31:24.4972025Z
2020-10-02T14:31:25.1698380Z npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/watchpack-chokidar2/node_modules/fsevents):
2020-10-02T14:31:25.1752251Z npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
2020-10-02T14:31:25.1805284Z npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_modules/fsevents):
2020-10-02T14:31:25.1807947Z npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
2020-10-02T14:31:25.1809039Z
2020-10-02T14:31:25.1840360Z added 821 packages from 472 contributors and audited 823 packages in 14.647s
2020-10-02T14:31:25.6118300Z
2020-10-02T14:31:25.6119530Z 32 packages are looking for funding
2020-10-02T14:31:25.6120300Z run `npm fund` for details
2020-10-02T14:31:25.6120873Z
2020-10-02T14:31:25.6130358Z found 0 vulnerabilities
On average, how much does actions/cache improve the install speed? Is this normal? I expected a bigger improvement. I think it will be faster if I cache the node_modules
folder itself, instead of ~/.npm
, but I’m guessing that can lead to unexpected behavior…
Am I using actions/cache properly?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:7 (1 by maintainers)
Top Results From Across the Web
npm cache does not speed up npm install #385 - GitHub
Although the build at "setup-node-with-cache" successfully uses npm cache (as evident by the output of the Run actions/setup-node@v2 step), run ...
Read more >How to speed up an already cached pip install? - Stack Overflow
Now pip has a download url, checks against the download cache folder ... My guess is that we could save a lot of...
Read more >How to Clear Cache on Android (And When You Should)
In most cases, clearing the cache from a few problematic apps can resolve storage or performance issues. Follow these steps to clear cached ......
Read more >Caching is very slow for Node.JS projects - gitlab-runner
Hi, I've tried now several cache configurations to speed up the builds ... a fresh install is now much faster than using the...
Read more >How to Clear Your Android Cache & Why You Should Do It
Learn how to clear your Android cache to boost speed and free up space. Then, optimize your phone even more with a free...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In my experiemnts, it actually slowed down the build. I had to add node action, cache action, and
npm i
is the same at best, usually 1-2 sec slower.I thought im using the best case scenario step for it, because im installing puppeteer which is like 100mb every install.
Is there any benefit of using this action at all in nodejs?
All it does is that it caches the downloads, not the built stuff is what I would believe.