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

Speed up workflow build caching #189

Merged
merged 3 commits into from
Jul 21, 2021
Merged

Conversation

strokovok
Copy link
Member

@strokovok strokovok commented Jul 17, 2021

  • Remove default caching mechanism. Contents of ~/.cargo are now shared across runs since all runners are now on the same machine. Caching of target directory using remote storage is not efficient and can be implemented faster as written below.
  • Wrap Rust compiler with sccache, which partly allows to reuse compiled dependencies (it's also mentioned here). Currently, there are 481mb of cache-hittable artifacts.
  • Share target/debug and target/release across runs. This allows profits even on partial cache-hit from previous builds + saves a lot of disk space for us :)

@strokovok strokovok changed the title Try speeding up workflow caching Speed up workflow build caching Jul 21, 2021
@strokovok strokovok marked this pull request as ready for review July 21, 2021 08:17
@strokovok strokovok requested a review from artob as a code owner July 21, 2021 08:17
@joshuajbouw joshuajbouw self-requested a review July 21, 2021 08:53
Copy link
Contributor

@joshuajbouw joshuajbouw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmm, yeah conceptually this looks ok. Why the move away from cache@v2 though?

@strokovok
Copy link
Member Author

Why the move away from cache@v2 though?

Well, cache@v2 works like this:

  • In case of cache-hit it downloads ~700mb archive from GitHub storage and unzips it
  • In case of cache-miss it builds from scratch, zips all artifacts (2.5GB -> 700mb) and uploads archive to GitHub storage
  • Both of this steps work ~40secs in our case
  • GitHub storage is limited to 5GB, so this cache-packages do not live long :)
  • One change of dependency completely invalidates cache

There are multiple reasons to get rid of it:

  1. Since we have our own machine with a lot of memory, we don't need to spend time for zipping/unzipping/uploading/downloading. We just can copy all the files as they are to some local cache in less than 1 second.
  2. In case of cache@v2 it's only possible to work with huge monolith archives - one change of some dependency changes the hash and completely invalidates the whole cache. With our own machine we are able to use partial cache invalidation which significantly increases cache-hit probability for single dependency

@joshuajbouw
Copy link
Contributor

Makes sense. Thanks for the explanation and the care and attention to that assessment.

@joshuajbouw joshuajbouw merged commit fc51f9a into develop Jul 21, 2021
@joshuajbouw joshuajbouw deleted the workflow-cache-speedup-exp branch July 21, 2021 12:54
artob added a commit that referenced this pull request Jul 30, 2021
* JSON: fix bugs and add unit tests. (#141)
* Add storage layout debug support for `EvmErc20.sol`. (#178)
* ERC-20: forbid using invalid NEP-141 AccountID for mapping. (#179)
* Add EIP-2930 support. (#181, #182)
* Migrate all workflows to self-hosted runners. (#185)
* Speed up the workflow using build caching. (#189)
* Use the new math API host functions. (#190)
* Fix `clippy::enum_variant_names` warning. (#192)
* Add different networks to the Makefile. (#193)
* Update the network status in the README. (#194)
* Remove the toolchain installation step in workflows. (#195)
* Run all tests for all networks in CI. (#196)
* Optimize for performance instead of code size. (#197)
* Parallelize the test suites. (#198)
* Add build-caching to the testing workflow. (#201)
* Refactor tests to use Signer. (#203)
* Add options to the bench profile. (#204)
* Remove a duplicate test. (#205)
* Add a sanity test for access list handling. (#206)
* Update nearcore to the latest branch.
* Add feature gates to the SDK's new host functions.

Co-authored-by: Ahmed Ali <ahmed@aurora.dev>
Co-authored-by: Dmitry Strokov <dmitry@aurora.dev>
Co-authored-by: Evgeny Ukhanov <evgeny@aurora.dev>
Co-authored-by: Joshua J. Bouw <joshua@aurora.dev>
Co-authored-by: Kirill <kirill@aurora.dev>
Co-authored-by: Michael Birch <michael@aurora.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants