nannou-org / nannou

A Creative Coding Framework for Rust.
https://nannou.cc/
6.02k stars 304 forks source link

Improving iterative compile times for projects depending on nannou #387

Open mitchmindtree opened 5 years ago

mitchmindtree commented 5 years ago

Slightly related to #178 but more focused on iterative compile times than fresh ones.

Currently it's easy to reach fairly significant compile times even for small projects (e.g. 10+ secs). I think there's likely a lot we could do to improve this situation with the design of nannou itself.

Here are some steps I think we could take:

Any other ideas are welcome!

I've labelled this as good-first-issue as this might be a nice way to become familiar with a lot of nannou's internals and rust benchmarking tools.

mitchmindtree commented 5 years ago

Some interesting discussion on this issue popping up here.

michal-z commented 4 years ago

On Windows using LLVM lld-link.exe instead of MS linker improves build times. Please see here: https://github.com/rust-gamedev/wg/issues/50

mystal commented 4 years ago

On another project I'm working on, the biggest compile time improvements were:

  1. Use lld to link on supported platforms.
  2. For debug builds, set debug = false to remove all debug info from the binaries. I rarely use a debugger to debug Rust, and having this turned on increases the build time quite a bit! So I have it off by default and toggle it on if I ever need to attach a debugger.
  3. Deduplicate dependencies when possible--i.e. only have one version of each dependency, especially syn/quote. This is less of a problem for incremental compilation, but I think it helps.
kazimuth commented 4 years ago

See also the "enable fast compiles" section of the Bevy setup guide: https://bevyengine.org/learn/book/getting-started/setup/

I've found that switching to those settings + a nightly compiler greatly speeds things up. It takes my mid-sized sketches (2-400 LOC) to 1second incremental recompiles. Adding debug=false to debug builds speeds things up even more, and you'll still get stack traces on panic, debuggers just won't work.