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

feat(benchmark infra) Add beforeEachBatchAsync callback #23391

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

markfields
Copy link
Member

@markfields markfields commented Dec 20, 2024

Description

Fixes AB#19814

This adds an async version of beforeEachBatch, to allow awaiting async code before running a batch of benchmark cycles.

@markfields markfields requested review from Copilot, CraigMacomber and alexvy86 and removed request for Copilot December 20, 2024 20:28
@github-actions github-actions bot added the base: main PRs targeted against main branch label Dec 20, 2024
@markfields markfields requested a review from Abe27342 December 20, 2024 20:29
Copy link
Contributor

@alexvy86 alexvy86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC there's a pattern somewhere in the benchmark package on how to use the sync VS async functions. I'm not sure I agree with just replacing beforeEachBatch with beforeEachBatchAsync withing runBenchmarkAsync is the right way to go. If the beforeEachBatch function is not async but the benchmarkFn is, I think it's still valid to use sync beforeEachBatch inside runBenchmarkAsync, unless we rewrite the contracts and the docs a bit, so BenchmarkRunningOptionsAsync can only take the async version of everything.

Depending on the final way we go, we might need to document this as a breaking change for the package (bump version to 0.52 and add an entry to CHANGELOG.md). Related: I think somewhere I might have a branch with the updated CHANGELOG that includes the changes in 0.51, I'll see if I can find it.

@markfields
Copy link
Member Author

If the beforeEachBatch function is not async but the benchmarkFn is, I think it's still valid to use sync beforeEachBatch inside runBenchmarkAsync,

You're so right! I thought about this briefly then promptly forgot. Should I run both beforeEachBatch's in the async case...?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
base: main PRs targeted against main branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants