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

Remove futures-util dependency #507

Closed
jplatte opened this issue Jan 7, 2021 · 7 comments · Fixed by #721
Closed

Remove futures-util dependency #507

jplatte opened this issue Jan 7, 2021 · 7 comments · Fixed by #721

Comments

@jplatte
Copy link

jplatte commented Jan 7, 2021

h2 currently depends on futures-util, which is rather heavy (containing heaps of combinators, plus pulling in most of the other futures-* crates) for only two things: poll_fn and AtomicWaker. poll_fn could trivially be copy-pasted (and is also coming to std so eventually that could be used), but the same thing is not true for AtomicWaker. I am not really familiar with the details of wakers, so don't really know how feasible it is to replace that / whether there's maybe an equivalent in tokio / tokio-utils.

I hope there is some new info in this issue. If somebody knows about a good replacement for futures-util's AtomicWaker, I'd be happy to create a PR removing the futures-util dependency.

@paolobarbolini
Copy link
Contributor

paolobarbolini commented Jan 7, 2021

This might be a good replacement https://crates.io/crates/atomic-waker, although very few crates seem to be using it. A better option might be to disable as many features as possible in imports for futures-util, which h2 is already doing by disabling all default features.

@jplatte
Copy link
Author

jplatte commented Jan 7, 2021

Oh hey, that's literally

futures::task::AtomicWaker extracted into its own crate.

Also, it's owned by smol-rs, so maintained by reputable folks.

@carllerche @seanmonstar wdyt? Would a PR replacing futures-util by atomic-waker + a copy-pasted std::future::poll_fn be welcome?

@taiki-e
Copy link
Contributor

taiki-e commented Jan 8, 2021

heavy

Is this still a problem even if the next version of futures-util is released? (rust-lang/futures-rs#2273)
If it can solve the problem, I can publish it.

(Also, note that relying on atomic-waker crate will eventually increase compile time, even if the compile time of h2 alone is shortened.)

@taiki-e
Copy link
Contributor

taiki-e commented Jan 8, 2021

fyi rust-lang/futures-rs#2307

@taiki-e
Copy link
Contributor

taiki-e commented Jan 8, 2021

I think we can close this as futures-util 0.3.9 has been released. (All of the main users of this crate seem to depend on futures-util, so adding a dependency like atomic-waker will only increase their compile time.)

@jplatte
Copy link
Author

jplatte commented Jan 8, 2021

I don't think so. Yes, you reduced the dependencies of futures-util which is pretty nice, but futures-util itself takes almost 4s to compile, before and after, in your own benchmark. Also, h2 still depends on pin-project (through tracing-futures) although on an old version, so it probably benefits some by only having a dependency to one version of it now.

You are right about many reverse dependencies of h2 (including hyper, hyper-rustls, reqwest) also depending on futures-util. I will look into whether they use equally small portions of it and try to follow up on their respective issue trackers if that is the case. I'll close this issue if it turns out to not be feasible to remove it from those projects.

Feel free to ping me on any relates issues on rust-lang/futures-rs 🙂

@paolobarbolini
Copy link
Contributor

I looked into it, since I also use hyper-rustls, and I was able to send this PR to completely remove futures-util rustls/hyper-rustls#142

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants