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

Make UnsignedBytes.lexicographicalComparator() use Arrays.compareUnsigned when it's available. #7611

Closed
wants to merge 0 commits into from

Conversation

copybara-service[bot]
Copy link
Contributor

Make UnsignedBytes.lexicographicalComparator() use Arrays.compareUnsigned when it's available.

This provides another alternative to using Unsafe.

And port the benchmark to JMH, which for now means making it Google-internal. (Not that we have our Caliper benchmarks actually running externally, either, IIRC.)

The benchmarks suggest that the old, Unsafe-based implementation is faster up to 64 elements or so but that it's a matter of only about a nanosecond. The new implementation pulls ahead for larger arrays, including an advantage of about 5-10 ns for 1024 elements.

For now, I've included this implementation only in the JRE flavor of Guava. We could include it in the Android flavor, too, to see if it helps under API Level 33+. But we really would want to do yet more benchmarking for that.

RELNOTES=n/a

@copybara-service copybara-service bot closed this Jan 10, 2025
@copybara-service copybara-service bot deleted the test_713020393 branch January 10, 2025 20:09
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.

0 participants