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

Support for async functions #39

Open
quambene opened this issue Dec 5, 2023 · 5 comments
Open

Support for async functions #39

quambene opened this issue Dec 5, 2023 · 5 comments
Labels
enhancement New feature or request

Comments

@quambene
Copy link

quambene commented Dec 5, 2023

I was trying out divan, and I'm wondering if there is support for benchmarking async functions, e.g. using a tokio runtime (cf. https://bheisler.github.io/criterion.rs/book/user_guide/benchmarking_async.html#benchmarking-async-functions)?

Feel free to close this issue if this was answered elsewhere.

@nvzqz nvzqz added the enhancement New feature or request label Dec 5, 2023
@nvzqz
Copy link
Owner

nvzqz commented Dec 5, 2023

I plan to support async functions and have some code in progress for it. This will likely come soon after allocation profiling. It wouldn't be until after or during the end of the month.

@nvzqz
Copy link
Owner

nvzqz commented Dec 12, 2023

Update: I now have an implementation of allocation profiling in #40. So maybe a week after that lands I'll get around to finishing async support.

@dan-da
Copy link

dan-da commented Mar 20, 2024

I'm glad to hear this is in progress. any update?

I recently converted a couple modules from sync to async. I have divan benches for them that I can't build with the new async implementations.

dan-da added a commit to dan-da/neptune-core that referenced this issue Mar 20, 2024
Moved this benchmark over from twenty_first.

Presently unable to build the twenty_first db_* bench tests because
the storage layer is now async and the divan bench crate doesn't yet
support async.  However, it may soon, see:

nvzqz/divan#39
dan-da added a commit to Neptune-Crypto/neptune-core that referenced this issue Apr 5, 2024
Moved this benchmark over from twenty_first.

Presently unable to build the twenty_first db_* bench tests because
the storage layer is now async and the divan bench crate doesn't yet
support async.  However, it may soon, see:

nvzqz/divan#39
@nvzqz
Copy link
Owner

nvzqz commented Jun 30, 2024

I'm currently prioritizing #10/#42 but I plan to support async benchmarks soon after. In the meantime, it seems folks have gotten acceptable results from just invoking block_on within the benchmark. My main motivation with async benchmarks is to move block_on overhead out of the sample time.

@king-11
Copy link

king-11 commented Sep 17, 2024

@nvzqz how does block_on work can you provide some insights I tried this it fails with panic that there is no reactor running, must be called from the context of a Tokio 1.x runtime

#[tokio::main]
async fn main() {
    divan::main();
}

#[divan::bench]
fn some_non_async_function(bencher: Bencher) {
  //
  bencher.bench(|| block_on(some_async_function()));
}

For more context some_async_function calls into tokio-postgres

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

No branches or pull requests

4 participants