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

Delegate Int|Short|Long.reverseBytes to Java Stdlib #414

Merged
merged 1 commit into from
Nov 19, 2024

Conversation

fzhinkin
Copy link
Collaborator

Seems like JVM's JIT compiler can't pattern match bytes reversal, so it's worth explicitly delegating to Java Stdlib functions, that are intrinsics candidates.

For long values, the new implementation shows 20% perf improvement for reversal itself.

Functions depending on it, like readXXXLe or writeXXXLe also show some moderate performance improvement from the change:

  • baseline (develop):
Benchmark                   (minGap)   Mode  Cnt          Score          Error  Units
IntLeBenchmark.benchmark         128  thrpt   15  387643797.206 ± 13843848.182  ops/s
LongLeBenchmark.benchmark        128  thrpt   15  314485977.158 ±  2249441.675  ops/s
ShortLeBenchmark.benchmark       128  thrpt   15  433907914.224 ±  6445437.883  ops/s
  • optimized (this PR):
Benchmark                   (minGap)   Mode  Cnt          Score          Error  Units
IntLeBenchmark.benchmark         128  thrpt   15  432487978.191 ± 29393229.522  ops/s
LongLeBenchmark.benchmark        128  thrpt   15  336771673.575 ±  6093734.967  ops/s
ShortLeBenchmark.benchmark       128  thrpt   15  440459420.611 ± 11852873.667  ops/s

Seems like JVM's JIT compiler can't pattern match bytes reversal,
so it's worth explicitly delegating to Java Stdlib functions,
that are intrinsics candidates.

For long values, the new implementation shows 20% perf improvement for reversal itself.

Functions depending on it, like readXXXLe or writeXXXLe also show
some moderate performance improvement from the change.
@fzhinkin fzhinkin marked this pull request as ready for review November 15, 2024 16:59
Copy link
Contributor

@shanshin shanshin left a comment

Choose a reason for hiding this comment

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

A good improvement for integers!

@fzhinkin fzhinkin merged commit ad14063 into develop Nov 19, 2024
1 check passed
@fzhinkin fzhinkin deleted the rev-bytes-delegate-to-java-stdlib branch November 19, 2024 13:31
@shanshin shanshin mentioned this pull request Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants