HADOOP-19839. PureJavaCrc32/Crc32C delegate to JDK CRC32/CRC32C#8349
Open
pan3793 wants to merge 2 commits intoapache:trunkfrom
Open
HADOOP-19839. PureJavaCrc32/Crc32C delegate to JDK CRC32/CRC32C#8349pan3793 wants to merge 2 commits intoapache:trunkfrom
pan3793 wants to merge 2 commits intoapache:trunkfrom
Conversation
|
🎊 +1 overall
This message was automatically generated. |
pan3793
commented
Mar 18, 2026
| * </code></pre> | ||
| * The output is in JIRA table format. | ||
| */ | ||
| public static class PerformanceTest { |
Member
Author
There was a problem hiding this comment.
checkstyle might complain about this, but it is mostly duplicated from the existing TestPureJavaCrc32$PerformanceTest
Member
Author
|
cc @aajisaka @steveloughran, could you please take a look? |
slfan1989
approved these changes
Mar 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of PR
PureJavaCrc32andPureJavaCrc32Care used as an alternative for lower JDKs, for both functionality and performance purposes, but they are not good reasons on modern JDKs.While they are public APIs, to avoid breaking changes, we keep them, but delegate the implementation to the JDK.
How was this patch tested?
Existing tests for compatibility and correctness.
Also, run the benchmark for performance - this patch makes PureJavaCrc32/Crc32C nearly identical to the JDK implementations. For trunk:
Here are the results (Java 17.0.15, OpenJDK 64-Bit, amd64, Linux):
TestPureJavaCrc32 — CRC32 vs PureJavaCrc32 (MB/sec)
At small sizes (≤64 bytes), PureJavaCrc32 is actually faster than java.util.zip.CRC32 (likely due to JNI call overhead). Above 128 bytes, CRC32 (hardware-accelerated via JNI) dominates significantly, reaching ~25 GB/sec at large sizes, while PureJavaCrc32 plateaus around ~2.2 GB/sec — roughly 85–95% slower.
TestPureJavaCrc32C — CRC32C vs PureJavaCrc32C (MB/sec)
java.util.zip.CRC32C (Java 9+ hardware CRC32C using SSE4.2) is consistently faster across all sizes. It peaks around ~30 GB/sec, while PureJavaCrc32C stays around ~2.1 GB/sec — roughly 82–97% slower.
Key observations at 1 thread, large buffers (≥1MB):
The pure Java implementations are consistent with each other (~2 GB/sec), while both JDK implementations leverage hardware acceleration for dramatically better performance. CRC32C has an additional advantage over CRC32 at typical buffer sizes (256B–4MB) due to more efficient SSE4.2 carryless multiplication.
For code changes:
LICENSE,LICENSE-binary,NOTICE-binaryfiles?AI Tooling
Contains content generated by: Claude Code Sonnet 4.6.
AI is used to summarize the benchmark report.
https://www.apache.org/legal/generative-tooling.html