-
-
Notifications
You must be signed in to change notification settings - Fork 740
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
GH2099: Add assembly gen and caching #2584
GH2099: Add assembly gen and caching #2584
Conversation
cache is invalidated by file content changes
@patriksvensson any updates on this? |
@codeimpossible I think @mholo65 is the one who should review this 😄 |
We should likely also review and finalise this RFC before progressing any further with this PR. |
Yes, my comment on the RFC is one of the unresolved issues (I think) https://github.com/cake-build/rfcs/pull/2/files#r229862533 |
@codeimpossible Thank you very much for your pull request 👍 We received several pull requests for this feature. We decided to merge #2650, and the feature will be available in upcoming Cake 2.2. Because of the above reason I'll close this PR. Thank you again for your work on this |
This updates the Roslyn script generator to emit the generated code to a DLL. The DLL is stored in
.cache/
underneath the directory the Cake.dll resides in.This work is heavily influenced by the ideas in #2099 as inspiration as well as the posted RFC: https://github.com/cake-build/rfcs/pull/2/files#diff-9b01d3179a039b60e4fcdb5e273d48c2.
If the cached assembly exists it will be loaded and executed, unless the
--recompile
flag is sent as an arg into cake.For a bit more context, you can check out the original PR on our fork: hudl#1.
Results
I ran the new cake version against an internal project that we have that uses cake (one of many) and recorded the execution times of a fresh run and a cached run. FYI the paths still show cake 0.33.0 but that is just because I replaced the cake files there with the built ones from this branch (see "How do I test this?" below).
Fresh run
Cached run
How do I test this?
./build.ps1
from the root./artifacts/v0.35.0-HUDL-SpikeAddAss0001/Cake-bin-coreclr-v0.35.0-HUDL-SpikeAddAss0001.zip
file and replace the contents ofcake.coreclr
in your marvel projectstools
directory. Then you can rundotnet <path/to/cake.dll> <path/to/build.cake> --target=<TARGET> --verbosity=Diagnostic --cache_enabled=true
to run the new cake version with the verbose logs turned on for more context.How the cache is invalidated
The cache is invalidated by any cake script changes. This adds ~2s to the execution time in my testing (because the analyzer has to run and hash all the script files). Still, reducing pre-script "build time" from 10s to 3s is still pretty impressive.
I updated the code so that the cache can be enabled via the built-in cake configuration, either with
CAKE_CACHE_ENABLED=true
andCAKE_CACHE_FORCE_RECOMPILE=true
environment variables,--cache_enabled=true --cache_force_recompile=true
args, or by adding the following to the cake.config:Default values for both of these are
false
.