-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Try using hyper instead of actix for webserver #782
Comments
If we're worrying about compilation time, dependencies and final binary size, how about using feature flags so users can compile only the features they need? It could look like this. The default feature flags for the crate can include all features so users running Other possible candidates for feature flags:
|
That's not really the issue, zola is not distributed on crates.io so the speedup is only for people working on the code itself or for package managers building from scratch and in that case features would be more annoying than anything since they would all be enabled everytime. |
As mentioned in that reddit thread, is using cobalt's serve.rs an option? Not too familiar with how zola has been doing static serving but cobalt's solution seems easily extendable/modifiable. |
That's probably the first thing to try yes. That and tiny-http which might be ok too |
I've been thinking about this exact topic for some time (after upgrading Zola's Actix version to 1.0) and had intended to create an issue to discuss it but I wanted to create a proof of concept first and never found the time. It's good to see that the idea's getting some traction. My thought was that Zola already includes Hyper because the reqwest crate is used in the One thing to mention is that right now Hyper is undergoing changes related to async/await for its next release (0.13). Both Hyper and Tokio (which Hyper uses) have alpha versions that use async/await but I don't believe they'll release until async/await is stablized in Rust 1.39.0. The latest commit to reqwest (as of September 6) refactors it to use async/await (using the Hyper 0.13 alpha), so that's forthcoming as well. I might tinker with this if I get some free time (no guarantees) but I at least wanted to comment, since this has been on my mind as well. |
It doesn't have to be on the next release of Zola, just something to keep in mind. Let's wait to see what Hyper 0.13 looks like, bumping the min required version for Zola is not an issue. |
hyper 0.13 has been released if anyone wants to have a go at that issue. |
If no one else takes this on, I'll try to get to it sometime soon. I've been maintaining a branch that uses the alpha versions of reqwest 0.10 (which requires some small changes), so that part's done, at least. I just need to find the time to sit down and work out the hyper server. |
I put some time into this today and built a standalone prototype using hyper. Thankfully, the hyper-staticfile crate was updated for hyper v0.13 yesterday, so that saved me from having to write a lot of boilerplate code to serve static files. At this point, I still need to tidy things up a little and integrate this into Zola's serve function but it's coming along. Once it's all sorted, I'll create a draft PR for review. |
I have the serve command running on hyper 0.13 and it seems to be working as expected after a quick test. I had to wrestle with getting it running in a separate thread (like the current setup) but I finally sorted it out last night. I still need to test it more and maybe clean it up a little but it's pretty much done at this point. Now that the Rust 2018 edition PR has been merged, the next step is to upgrade reqwest. The upcoming 0.10 version of reqwest uses hyper 0.13 and it seems like a release will happen sometime soon. I've been developing against the master branch of the Git repo, since the latest alpha release still uses alpha versions of hyper, tokio, etc. I've created a draft PR for the reqwest 0.10 update (#892), so we can work out any implementation details while we wait for 0.10 to release. |
I've created a draft PR (#904) for the hyper 0.13 migration (based on the draft reqwest 0.10 PR), if anyone wants to test it out. We still have to wait for the reqwest 0.10 release before this can move forward but it seems quite close now. |
To see if it helps in terms of compilation time/number of deps (on
next
branch)See https://www.reddit.com/r/rust/comments/ctlt16/thoughts_on_rust_bloat/exnrn0i/
The text was updated successfully, but these errors were encountered: