Lock and characterize Avro VarHandle float/double decoding behavior - #2
Draft
jaipilot[bot] wants to merge 1 commit into
Draft
Conversation
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.
Before
The PR under evaluation (mirroring upstream jackson-dataformats-binary#762) adds
AvroVarHandleUtiland wires it intoJacksonAvroParserImpl.decodeFloat()/decodeDouble()to read little-endian IEEE-754 bytes via a singleVarHandleaccess instead of 4/8 sequential byte-shift-and-mask operations, with a byte-shifting fallback for runtimes lackingVarHandle. The only existing coverage (AvroNumberTest.testNumberCoercions) exercised a single float (0.125f) and double (-3.75) value.Changes in this companion
AvroVarHandleUtilTest(new packagetools.jackson.dataformat.avro.desertest class) directly characterizinggetIntLE/getLongLE's little-endian byte layout: zero, positive, negative/sign-bit values, and non-zero offsets.AvroNumberTest.testFloatEdgeCasesRoundTrip/testDoubleEdgeCasesRoundTrip, round-tripping IEEE-754 boundary values (+-0,+-1,MIN_VALUE/MAX_VALUE/MIN_NORMAL,NaN,+-Infinity, typical fractions) through the real Avro writer/reader, from both a plain byte array and aLimitingInputStreamthat forces the buffer-refill (_loadToHaveAtLeast) code path used mid-stream bydecodeFloat/decodeDouble. Verified bit-exact viafloatToRawIntBits/doubleToRawLongBits.opens tools.jackson.dataformat.avro.deser;line toavro/src/test/java/module-info.java, required for the new test class to run under the project's JPMS test module.JacksonAvroParserImpl._checkVarHandleAvailable(), matching the single-blank-line convention used at the identical spot in the siblingSmileParserBase.Behavior preservation
All 13 focused tests (4 in
AvroNumberTest, 9 inAvroVarHandleUtilTest) pass identically before and after the production whitespace edit, using the exact same command. The fullavromodule test suite and the complete multi-module./mvnw clean installboth pass.Performance
A standalone microbenchmark (5 runs each, JDK 21) confirms the PR's own optimization is real:
AvroVarHandleUtilreads run faster than the byte-shifting fallback it guards (int: median 74.76ms vs 88.20ms per 20M reads; long: median 83.23ms vs 141.03ms). No further production change was made -- see the performance pass detail for what was considered and rejected.Limitations
VarHandle) is exercised only indirectly through this evidence, not through an actual non-VarHandle JVM, consistent with how the analogous Smile/CBOR utilities are covered in this repository.Generated by JAIPilot Cloud for #1 from Anthropic session
sesn_01DuzYQtLUhVzKRiEUHwAXb1.