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

--usenimcache (implied by nim r main) now caches some compile options to avoid recompiling when project was previously compiled with such options. #17829

Merged
merged 5 commits into from
Apr 25, 2021

Conversation

timotheecour
Copy link
Member

@timotheecour timotheecour commented Apr 24, 2021

this PR improves the compilation cache, and in particular nim r, --usenimcache, -d:nimbetterrun

--usenimcache (implied by nim r main) now generates an output file that includes a hash of some of the compilation options, which allows caching generated binaries

example

nim r main # recompiles
nim r -d:foo main # recompiles
nim r main # uses cached binary
nim r main arg1 arg2 # ditto (runtime arguments are irrelevant)

see tests

before this PR

nim r main # recompiles
nim r -d:foo main # recompiles
nim r main # bad: recompiles (after this PR, does not recompile)
nim r sub/main # recompiles
nim r main # bad: recompiles (after this PR, does not recompile)

notes

future work

  • (preexisting limitation) nimbetterrun (and writeJsonBuildInstructions etc) isn't supported with js backend, but there's not reason it shouldn't
  • writeJsonBuildInstructions + friends should just reuse std/json, it'll simplify code. simpler = better.
  • [tooling] cache compilation to avoid recompiling when possible RFCs#107 meantions another useful features that would be nice to implement: garbage collection, using an LRU cache of cached binaries

…ions

to avoid recompiling when project was previously compiled with such options.
@timotheecour timotheecour added the TODO: followup needed remove tag once fixed or tracked elsewhere label Apr 24, 2021
@timotheecour timotheecour marked this pull request as ready for review April 24, 2021 03:31
@timotheecour timotheecour added the Ready For Review (please take another look): ready for next review round label Apr 24, 2021
compiler/main.nim Outdated Show resolved Hide resolved
@Araq Araq merged commit ffe4328 into nim-lang:devel Apr 25, 2021
@timotheecour timotheecour deleted the pr_betterrun_hash_options branch April 25, 2021 15:53
@ringabout ringabout removed the Ready For Review (please take another look): ready for next review round label Apr 26, 2021
PMunch pushed a commit to PMunch/Nim that referenced this pull request Mar 28, 2022
…ions to avoid recompiling when project was previously compiled with such options. (nim-lang#17829)

* `--usenimcache` (implied by `nim r main`) now caches some compile options
to avoid recompiling when project was previously compiled with such options.

* works
* add test
* changelog
* use std/with
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TODO: followup needed remove tag once fixed or tracked elsewhere
Projects
None yet
3 participants