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

Ability to invoke all std benchmarks via jmh #7519

Conversation

Akirathan
Copy link
Member

@Akirathan Akirathan commented Aug 8, 2023

Closes #7489

Pull Request Description

Important Notes

  • All the benchmarks have configured phases (number of iterations/seconds for warmup or measurement) such that the total number of benchmark invocations per warmup and measurement is somewhere around 100 at least and their score is not less than 1 ms.
  • There is yet no API for providing setup or teardown methods.
    • An example of how lazy setup can be done for Text/compare is in 3ca6cd7
    • Without the lazy setup, the collection of benchmarks in Text/compare takes 7 seconds, with lazy setup, the collection takes 160 ms.

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • The documentation has been updated, if necessary.
  • Screenshots/screencasts have been attached, if there are any visual changes. For interactive or animated visual changes, a screencast is preferred.
  • All code follows the
    Scala,
    Java,
    and
    Rust
    style guides. In case you are using a language not listed above, follow the Rust style guide.
  • All code has been tested:
    • Unit tests have been written where possible.
    • If GUI codebase was changed, the GUI was tested when built using ./run ide build.

@Akirathan Akirathan self-assigned this Aug 8, 2023
@Akirathan Akirathan mentioned this pull request Aug 8, 2023
5 tasks
Copy link
Member

@JaroslavTulach JaroslavTulach left a comment

Choose a reason for hiding this comment

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

Perfect and sufficient, in my opinion.

Copy link
Member

@radeusgd radeusgd left a comment

Choose a reason for hiding this comment

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

This looks perfect! ❤️

Copy link
Member

@JaroslavTulach JaroslavTulach left a comment

Choose a reason for hiding this comment

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

As far as I can say we don't need teardown right now. As such, please let's keep this pull request simple and focused. Let's use existing Enso language lazy atom fields concept to get proper setup behavior without changing the BenchProcessor, without introducing set_setup and set_teardown and without having problems to invoke these methods from JMH.

distribution/lib/Standard/Test/0.0.0-dev/src/Bench.enso Outdated Show resolved Hide resolved
distribution/lib/Standard/Test/0.0.0-dev/src/Bench.enso Outdated Show resolved Hide resolved
test/Benchmarks/src/Vector/Distinct.enso Outdated Show resolved Hide resolved
test/Benchmarks/src/Vector/Distinct.enso Outdated Show resolved Hide resolved
test/Benchmarks/src/Vector/Distinct.enso Show resolved Hide resolved
test/Benchmarks/src/Vector/Distinct.enso Outdated Show resolved Hide resolved
@Akirathan
Copy link
Member Author

As far as I can say we don't need teardown right now. As such, please let's keep this pull request simple and focused. Let's use existing Enso language lazy atom fields concept to get proper setup behavior without changing the BenchProcessor, without introducing set_setup and set_teardown and without having problems to invoke these methods from JMH.

Sounds like a good idea. I reverted all the commits that introduced the special API for setup and teardown methods. For future reference, it is kept in a new issue #7566.

Copy link
Member

@radeusgd radeusgd left a comment

Choose a reason for hiding this comment

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

The direction looks good and I agree with @JaroslavTulach on setup/teardown - let's keep it simple. I think computing the lazy values on first warmup iteration should be acceptable - it's warmup after all. We just should make sure that they are indeed not recomputed in the measurement phase.

And let's ensure the data for benchmarks is always computed lazily so it is not computed in the 'gathering benchmark structure' phase, as it may slow it down.

Copy link
Member

@JaroslavTulach JaroslavTulach left a comment

Choose a reason for hiding this comment

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

I see the CI is green. I think the current state is good. Approving.

builder = Vector.new_builder

# Vector
builder.append Array_Proxy_Bench.collect_benches
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't all the collect_benches method accept a Bench.builder? Then this would be:

Bench.build builder ->
  Array_Proxy_Bench.collect_benches builder
  Distinct.callect_benches builder
  ...

Then we wouldn't need to iterate Vector, but rather:

main =
    all_benchmarks . run_main

@Akirathan Akirathan marked this pull request as ready for review August 17, 2023 10:03
@Akirathan
Copy link
Member Author

The GH Workflow is added in #7597. Since we need to first merge #7597 to try the new action, let's already merge this PR. I will also revert the commits that contain the CI-related changes.

@Akirathan Akirathan added the CI: No changelog needed Do not require a changelog entry for this PR. label Aug 17, 2023
@Akirathan Akirathan merged commit a0086bb into develop Aug 17, 2023
24 checks passed
@Akirathan Akirathan deleted the wip/akirathan/7489-Ability-to-invoke-all-std-benchmarks-via-JMH branch August 17, 2023 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: No changelog needed Do not require a changelog entry for this PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ability to invoke all std-benchmarks via JMH
3 participants