rwf2 / Rocket

A web framework for Rust.
https://rocket.rs
Other
24.55k stars 1.57k forks source link

Long compilation time from git #1240

Closed incker closed 4 years ago

incker commented 4 years ago

Hello.

I was using rocket 0.4 until now. But I have some problems with dependency named ring or something like that, when i tried to install new versions of tokio or tgbot

So, I decided to move to rocket 0.5 and I modified my Cargo.toml Code:

[dependencies]
rocket = { git = "https://github.com/SergioBenitez/Rocket", rev = "9f0e02f", default-features = false }
# other fields omited

[dependencies.rocket_contrib]
git = "https://github.com/SergioBenitez/Rocket"
rev = "9f0e02f"
version = "0.5.0-dev"
default-features = false
features = ["json", "serve", "diesel_mysql_pool"]

Everything works, but my compilation time while developing have risen from seconds to 4m 23s 😒

I am not sure where exactly the problem is, the target folder is still 3 Gb as like in rocket 0.4 If you will not see problem on the surface - I would like make some more experiments

Maybe because I use dependency from git but not from crates? maybe it have sense to publish rocket 0.5 alpha to crates io?

jebrosen commented 4 years ago

Everything works, but my compilation time while developing have risen from seconds to 4m 23s

4m 23s on each compilation? That is definitely surprising, and not something I have experienced when using git dependencies. Generally, that long build time should happen approximately once each for check, build(debug), build(release), and test configurations.

If you haven't done it already, a single cargo clean + rebuild will clear the cached compiled artifacts in target/, which might prevent the problem from reoccurring.

incker commented 4 years ago

Thank you for your reply.

I have made a docker container with pure rocket. And it has compilation time 50 seconds on every change.

https://github.com/incker/rocket_long_compile_example

50 seconds is not 4m 23s but I think it is any way a lot, because here are only 30 lines of code. Maybe error exactly in rust nightly, but I am even not sure what and where to bug report

Thank you for any help

vultix commented 4 years ago

I had a similar problem once, and it was resolved by removing sccache. Is there any chance you are using sccache?

incker commented 4 years ago

Looks like error in rust nightly. Not sure how to solve it for now, but it is not rocket problem.

I will close this issue

cbzehner commented 4 years ago

That sounds pretty frustrating, even 50 seconds is quite a long time to wait for re-compilation.

I took a quick look at the Dockerfile in the example you provided and noticed it's not using any layers. So part of the reason for your long compile times might be due to a lack of caching in the Docker environment.

I've been using this Dockerfile for my development environment in a couple of projects using Rocket and seeing compile times below 20 seconds pretty consistently.

Take a look if you have some time.

incker commented 4 years ago

Thank you! Looks like it can help)

incker commented 4 years ago

@cbzehner You see, I have in docker-compose.yml such line: cargo watch -w ./src/ --poll -x run I mean that I am not waiting rebuild docker on every change: Docker starts once, but cargo watch just making rebuilds every time I save (press Ctrl + S) I think using cargo watch -x run or cargo watch -x test is better solution for developing than try to speed up docker

P.S. For now I fixed that just installing ubuntu without using docker) Heh) Now my rebuild time is 8 seconds after previous 4.30 minutes. I am not sure where problem is. Maybe I have broken a little some windows virtualizing somewhere