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

Shall quadratic complexity of join_all be documented? #2201

Closed
vi opened this issue Aug 26, 2020 · 11 comments · Fixed by #2412
Closed

Shall quadratic complexity of join_all be documented? #2201

vi opened this issue Aug 26, 2020 · 11 comments · Fixed by #2412
Labels
A-future Area: futures::future docs

Comments

@vi
Copy link
Contributor

vi commented Aug 26, 2020

@Nemo157
Copy link
Member

Nemo157 commented Aug 26, 2020

Maybe even a

#[cfg(debug_assertions)]
if futures.len() > 1000 {
  warn!("join_all is only intended for running small dynamic lists of futures, use FuturesUnordered for large numbers");
}

(probably could even be a much lower limit, I don't know if anyone has ever tested what a good limit is).

@vi
Copy link
Contributor Author

vi commented Aug 26, 2020

Does futures really use log?

@Nemo157
Copy link
Member

Nemo157 commented Aug 26, 2020

Not currently, but the only other option I can think of would be debug_assert! which seems far too drastic to me.

@taiki-e
Copy link
Member

taiki-e commented Aug 28, 2020

(I think the fundamental solution is to change the name to include a word that describes its feature(=only efficient for relatively small lists), but that's a breaking change of course.)

@Darksonn
Copy link
Contributor

Another option would be to have it use FuturesUnordered internally when the number of futures is large.

@taiki-e taiki-e added this to the futures-0.4 milestone Dec 17, 2020
@taiki-e taiki-e added the A-future Area: futures::future label Dec 17, 2020
@EFanZh
Copy link
Contributor

EFanZh commented May 17, 2021

Does try_join_all and select_all suffer from the same issue?

@Darksonn
Copy link
Contributor

Yes. For try_join_all it is exactly the same. For futures::future::select_all, it's a bit harder to hit, but it's still there. (Note that futures::stream::select_all is a different story.)

@ibraheemdev
Copy link
Member

Is 30 a suitable limit? It could probably even be something lower, like 10, but it really depends on the cost of polling the specific future type.

@taiki-e
Copy link
Member

taiki-e commented Aug 30, 2021

#2412 is published in 0.3.17

@mox692
Copy link

mox692 commented Nov 19, 2023

I may be missing something, but is there a reason we are using FuturesOrdered instead of FuturesUnordered?

@Xuanwo
Copy link

Xuanwo commented Jan 19, 2024

I may be missing something, but is there a reason we are using FuturesOrdered instead of FuturesUnordered?

The order in which future results are returned is important.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-future Area: futures::future docs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants