Skip to content
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

Expected performance with caching? #914

Closed
swanson opened this issue May 11, 2021 · 1 comment
Closed

Expected performance with caching? #914

swanson opened this issue May 11, 2021 · 1 comment
Assignees
Labels

Comments

@swanson
Copy link

swanson commented May 11, 2021

I'm trying to speed up building our app and am confused about caching. From everything I can see, caching is enabled (the ENV VARs are set, the Restoring cache/Caching build steps are working), but running yarn install is still taking 180 seconds? (Done in 179.42s.)

I've tried running multiple builds from the same git commit, as well as new commits with no changes to the yarn.lock file.

-----> Building on the Heroku-20 stack
-----> Using buildpacks:
       1. https://github.com/gaffneyc/heroku-buildpack-jemalloc.git
       2. heroku/nodejs
       3. heroku/jvm
       4. heroku/ruby
-----> jemalloc app detected
-----> jemalloc: Vendoring 5.2.1
-----> jemalloc: Building runtime environment
-----> Node.js app detected
       
-----> Creating runtime environment
       
       NPM_CONFIG_LOGLEVEL=error
       YARN_PRODUCTION=true
       USE_YARN_CACHE=true
       NODE_VERBOSE=false
       NODE_ENV=production
       NODE_MODULES_CACHE=true
       
-----> Installing binaries
       engines.node (package.json):  unspecified
       engines.npm (package.json):   unspecified (use default)
       engines.yarn (package.json):  unspecified (use default)
       
       Resolving node version 14.x...
       Downloading and installing node 14.16.1...
       Using default npm version: 6.14.12
       Resolving yarn version 1.22.x...
       Downloading and installing yarn (1.22.10)
       Installed yarn 1.22.10
       
-----> Restoring cache
       - yarn cache
       
-----> Installing dependencies
       Installing node modules (yarn.lock)
       yarn install v1.22.10
       [1/4] Resolving packages...
       [2/4] Fetching packages...
       info [email protected]: The platform "linux" is incompatible with this module.
       info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
       [3/4] Linking dependencies...
       warning " > [email protected]" has unmet peer dependency "webpack@>=1.11.0".
       warning " > [email protected]" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0".
       warning "webpack-dev-server > [email protected]" has unmet peer dependency "webpack@^4.0.0".
       [4/4] Building fresh packages...
       Done in 179.42s.
       
-----> Build
       
-----> Pruning devDependencies
       Skipping because YARN_PRODUCTION is 'true'
       
-----> Caching build
       - yarn cache
       
-----> Build succeeded!
 !     Unmet dependencies don't fail yarn install but may cause runtime issues
       https://github.com/npm/npm/issues/7494

Later on in my pipeline when I get to the ruby buildpack (outside the scope of this repository/team I know), running yarn install again takes only 1.25 seconds.

yarn install v1.22.10
 [1/4] Resolving packages...
 success Already up-to-date.
 Done in 1.25s.

Is it expected that yarn install should be taking 180 seconds every build, even when caching is used? Or is the caching not working? Not sure how to best debug or diagnose the issue. Any advice?

@swanson
Copy link
Author

swanson commented May 13, 2021

I was able to debug more by turning on verbose mode for yarn install.

I added a .yarnrc file to my project with:

--install.verbose true

I was able to use this to see that my project was compiling a native package every time. Upgrading the relevant, project-specific dependency (webpacker in my case) removed the need for that and dropped the yarn install time from 180 seconds to 34 seconds!

After that, the caching got it down to 15 seconds for the yarn install step, so it seems to be working much better.

Leaving this comment in hopes that helps someone else debugging in the future!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants