ElektraInitiative / PermaplanT

https://www.permaplant.net
BSD 3-Clause "New" or "Revised" License
16 stars 13 forks source link

Improve Rust compile times #1210

Open horenso opened 8 months ago

horenso commented 8 months ago

Adding a newline to main.rs the backend and recompiling it takes ~8 seconds. This is a drag and there might be oportunities to improve this.

We could split up the backend into seperate crates, in Rust a crate is one compilation unit. As an experiment, I seperated the model (database and dto) into its own layer on this branch and it improved it already to ~5 seconds, but it was done very quicky and I believe it could be done much better.

How would the backend be split up?

There are different ways to structure projects in Rust. I suggest:

The backend directory:

Cargo.toml
lib-db/
   Cargo.toml
   ...
src/

What does this improve?

Disadvantages

It's not an urgent issue, but at some point when compile times increase we should spilt up the backend at some point.

markus2330 commented 8 months ago

Thank you for creating this issue!

The gain of compilation speed 8->5s is quite minimal and I also don't think there is much more potential (as afaik Diesel causes most of the compilation time).

Splitting up in 3 modules make sense, so that the module structure represents our architecture. But only if it does not involve too much time effort, as the gain is not huge.