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

Turning Sieve benchmarks into Enso benchmarks #8475

Merged
merged 6 commits into from
Dec 8, 2023

Conversation

JaroslavTulach
Copy link
Member

@JaroslavTulach JaroslavTulach commented Dec 6, 2023

Pull Request Description

Having the benchmarks in Enso will make it easier to rewrite certain parts of the algorithm to other languages.

Important Notes

Execute as

sbt:enso> runEngineDistribution --run test/Benchmarks Sieve

or as

sbt:enso> std-benchmarks/benchOnly Sieve

Checklist

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

  • All code follows the
    Java, Enso
    style guides.
  • All code has been tested:
    • Benchmarks can be executed
    • New benchmarks provide similar results as old ones

@JaroslavTulach JaroslavTulach self-assigned this Dec 6, 2023
@JaroslavTulach JaroslavTulach added the CI: No changelog needed Do not require a changelog entry for this PR. label Dec 6, 2023
@JaroslavTulach
Copy link
Member Author

Current results on my computer:

[info] Benchmark            Mode  Cnt    Score   Error  Units
[info] Sieve.Ascribed       avgt       291.542          ms/op
[info] Sieve.Original       avgt       289.745          ms/op
[info] Sieve.Without_Types  avgt       270.837          ms/op

}
return new Gen()

compute_nth_prime_natural_in_js = Sieve_Without_Types.compute_nth_prime gen=natural_in_js
Copy link
Member Author

Choose a reason for hiding this comment

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

These JavaScript benchmarks work with:

sbt:enso> runEngineDistribution --run test/Benchmarks Sieve

but not with std-benchmarks/benchOnly Sieve. Please help, @Akirathan!

@JaroslavTulach
Copy link
Member Author

JaroslavTulach commented Dec 6, 2023

a2acce6 adds JavaScript benchmarks. They however seem to show the price we pay for JavaScript interop is high!

[info] Sieve.Ascribed             avgt    3   268.487 ±   60.973  ms/op
[info] Sieve.Java_Script_All      avgt    3   888.633 ±  276.752  ms/op
[info] Sieve.Java_Script_Filter   avgt    3  1831.328 ± 4293.687  ms/op
[info] Sieve.Java_Script_Natural  avgt    3  2152.961 ±  804.918  ms/op
[info] Sieve.Original             avgt    3   278.269 ±  104.952  ms/op
[info] Sieve.Without_Types        avgt    3   274.963 ±   96.071  ms/op

Java_Script_Filter and Java_Script_Natural pay a price for interop - clearly not done at the fastest possible manner. But why Java_Script_All is slow remains a mystery - standalone benchmarks show JavaScript is faster than Enso.

Running official benchmarks and once again.

obrazek

The picture confirms (not surprisingly) that the "Enso Sieve Benchmarks" run at the same speed as the "JMH Sieve Benchmarks". E.g. we can integrate and use/watch the new benchmarks.

@@ -231,7 +231,7 @@ private void generateClassForGroup(
" throw new IllegalStateException(\"Project root directory does not exist or cannot be read: \" + Objects.toString(projectRootDir));");
out.println(" }");
out.println(" File languageHomeOverride = Utils.findLanguageHomeOverride();");
out.println(" var ctx = Context.newBuilder(LanguageInfo.ID)");
out.println(" var ctx = Context.newBuilder()");
Copy link
Member Author

@JaroslavTulach JaroslavTulach Dec 6, 2023

Choose a reason for hiding this comment

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

I thought it was going to be a classpath issue, not "restricted to Enso language" issue! Thank you for your help, @Akirathan!

@radeusgd
Copy link
Member

radeusgd commented Dec 6, 2023

But why Java_Script_All is slow remains a mystery - standalone benchmarks show JavaScript is faster than Enso.

Hmm this is very curious indeed 🤔

@JaroslavTulach JaroslavTulach added the CI: Clean build required CI runners will be cleaned before and after this PR is built. label Dec 7, 2023
Copy link
Contributor

@hubertp hubertp left a comment

Choose a reason for hiding this comment

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

Does it make sense to keep JMH benchmark as well - the more the merrier and gives us some reference?

@JaroslavTulach
Copy link
Member Author

Official results are here. Java_Script_File takes 70ms - that's the goal we'd like to reach one day... Original, Ascribed and Without_Types take 400+ms - they are purely written in Enso. E.g. Enso is 6 times slower than JavaScript. The other Java_Script_... benchmark somehow mix Enso and JavaScript - they are pretty slow - e.g. certainly there is a cost of crossing the polyglot boundary between Enso & JavaScript.

Sieve.Java_Script_File                                                avgt    3    70.976 ±      6.440  ms/op

Sieve.Ascribed                                                        avgt    3   440.056 ±     54.563  ms/op
Sieve.Original                                                        avgt    3   412.924 ±     30.009  ms/op
Sieve.Without_Types                                                   avgt    3   405.650 ±      6.148  ms/op

Sieve.Java_Script_All                                                 avgt    3  1123.099 ±    391.940  ms/op
Sieve.Java_Script_Filter                                              avgt    3  2609.217 ±   3943.999  ms/op
Sieve.Java_Script_Natural                                             avgt    3  3182.236 ±   7700.466  ms/op

@enso-bot
Copy link

enso-bot bot commented Dec 8, 2023

Jaroslav Tulach reports a new STANDUP for yesterday (2023-12-07):

Progress: - "removing JMH sieve": c849ff9

Next Day: Bugfix something

Discord
Discord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities.

@JaroslavTulach
Copy link
Member Author

Does it make sense to keep JMH benchmark as well - the more the merrier and gives us some reference?

Probably not. The results are the same with the Enso benchmarking infrastructure 400-420ms.

@JaroslavTulach JaroslavTulach merged commit e4b2b56 into develop Dec 8, 2023
33 of 34 checks passed
@JaroslavTulach JaroslavTulach deleted the wip/jtulach/SieveBenchmarksInEnso branch December 8, 2023 09:27
@enso-bot
Copy link

enso-bot bot commented Dec 11, 2023

Jaroslav Tulach reports a new STANDUP for the last Friday (2023-12-08):

Progress: - AoC: https://discord.com/channels/401396655599124480/1182572489025531955/1182572641333280860

Next Day: Bugfix something

Discord
Discord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: Clean build required CI runners will be cleaned before and after this PR is built. 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.

4 participants