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

libtest bench async/await support #71186

Closed
GopherJ opened this issue Apr 16, 2020 · 7 comments
Closed

libtest bench async/await support #71186

GopherJ opened this issue Apr 16, 2020 · 7 comments
Labels
A-libtest Area: #[test] related C-feature-request Category: A feature request, i.e: not implemented / a PR.

Comments

@GopherJ
Copy link

GopherJ commented Apr 16, 2020

can libtest offer b.iter_async to make it possible to run async functions?

b.iter_async(async {
  // async call
})

because it seems if we are using aynsc_std::task::block_on or other runtime, that may influence the result

@jonas-schievink jonas-schievink added A-libtest Area: #[test] related C-feature-request Category: A feature request, i.e: not implemented / a PR. labels Apr 16, 2020
@jonas-schievink
Copy link
Contributor

Which executor would iter_async use? Why is it better than the one in async-std?

@Mark-Simulacrum
Copy link
Member

I think this is major enough that we would need an RFC for it; it essentially means offering some executor in std/test. I suspect, though could also be wrong, that in particular for benchmarking that could be a bad idea (since you'd be benchmarking at least partially your executor, and std's is unlikely to be best-in-class for your specific problem).

@GopherJ
Copy link
Author

GopherJ commented Apr 16, 2020

@jonas-schievink I believe any executor can be used, I just don't want to create async runtime in bench iterator, because it will influence the result.

Instead of creating an async runtime in every bench iterator, why not create just one runtime and spawn tasks on it?

@GopherJ
Copy link
Author

GopherJ commented Apr 16, 2020

Or maybe bencher should be sperated into a crate so that we can use different runtime.

I found one but it's not maintained

@GopherJ
Copy link
Author

GopherJ commented May 10, 2020

I think this is major enough that we would need an RFC for it; it essentially means offering some executor in std/test. I suspect, though could also be wrong, that in particular for benchmarking that could be a bad idea (since you'd be benchmarking at least partially your executor, and std's is unlikely to be best-in-class for your specific problem).

I think we can also let b.iter_async accepts an executor, no need to have an executor in rust std side

b.iter_async_with(tokio::runtime::Runtime::new().unwrap(), async {
  // async call
})

Currently it's a pain to benchmark async code....

@Stargateur
Copy link
Contributor

also the [bench] attribute doesn't support async function.

aleics added a commit to aleics/bruc that referenced this issue Nov 7, 2020
Since the executor needs to be used inside the iter closure,
the results don't reflect fully the performance of running source,
but also the resources needed by the futures executor to await
for the results.

It seems like using async/await in benches is still WIP
(see issue: rust-lang/rust#71186)
@k06a
Copy link

k06a commented Feb 3, 2022

@Stargateur any progress on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-libtest Area: #[test] related C-feature-request Category: A feature request, i.e: not implemented / a PR.
Projects
None yet
Development

No branches or pull requests

5 participants