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

Proposal for a benchmark execution goal with JVM implementation #19172

Open
wants to merge 28 commits into
base: main
Choose a base branch
from

Conversation

alonsodomin
Copy link
Contributor

@alonsodomin alonsodomin commented May 27, 2023

This PR adds a new main goal to Pants under the alias bench (or may be better to put it under experimental-bench) with the sole purpose to execute microbenchmaks.

The PR provides as well an implementation for the JVM based on JMH (the most popular framework) and Scalameter.

The core goal implementation is blatantly inspired on the test goal (removing support for coverage data and debugging), and, if adding a new goal is considered unnecessary, the implementations could switch to be based off test instead. There is no consensus among developers of different communities and tooling on whether benchmarks are just tests or if they are a separate thing all together. For example in Go the standard is to use go test -bench=. while in Rust the command used is cargo bench.

The choice of putting them as separate comes from preventing unnecessary wait times when running tests (and not being aware that benchmarks are among those) and making the end user be intentional about their purpose. Happy to get rid of the goal though if we find that it as bloat.

The rest of the implementation follows a similar pattern as the one used for supporting JUnit: Having support for running JMH benchmarks in the 3 JVM languages supported with an extra for Scalameter.

tailor implementation is not based on a general consensus either, the choice of using Benchmark as a suffix for JMH and Bench for Scalameter is just made for convenience.

[ci skip-build-wheels]
[ci skip-rust]

@tdyas
Copy link
Contributor

tdyas commented May 29, 2023

What do bazel and other build systems comparable to Pants provide for invoking benchmarks?

@alonsodomin
Copy link
Contributor Author

I only looked a bit into a few impls in Bazel and it seems the approach the contributors are following are to execute them with the run command.

For example:

Haven't found any support at all in Buck. Please does support Go benchmarks via a specific target named go_benchmark and from the docs I gather these are run using the test goal instead: https://please.build/plugins.html#go

So support is very patchy. This is obviously something not standardized across language toolchains and much less on monorepo build tools.

@alonsodomin alonsodomin force-pushed the benchmarks_scalameter branch from 4b431ee to aca46ed Compare August 31, 2023 07:50
@alonsodomin alonsodomin force-pushed the benchmarks_scalameter branch from 1dbb1d8 to d9b8084 Compare December 22, 2023 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend: JVM JVM backend-related issues category:new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants