[Experimental] Add MemorySegment API support for zero-copy buffer I/O#2904
Draft
[Experimental] Add MemorySegment API support for zero-copy buffer I/O#2904
Conversation
Contributor
divang
commented
Mar 3, 2026
- Implement BufferAllocator interface with strategy pattern
- Add HeapBufferAllocator for traditional ByteBuffer (Java 8+)
- Add MemorySegmentBufferAllocator for zero-copy I/O (Java 22+)
- Update IOBuffer to use reflection-based factory for allocator selection
- Configure pom.xml for dual compilation (Java 8 + Java 22 targets)
- Add comprehensive performance comparison test suite
- System property: mssql.jdbc.useMemorySegment=true/false
- Implement BufferAllocator interface with strategy pattern - Add HeapBufferAllocator for traditional ByteBuffer (Java 8+) - Add MemorySegmentBufferAllocator for zero-copy I/O (Java 22+) - Update IOBuffer to use reflection-based factory for allocator selection - Configure pom.xml for dual compilation (Java 8 + Java 22 targets) - Add comprehensive performance comparison test suite - System property: mssql.jdbc.useMemorySegment=true/false
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2904 +/- ##
============================================
- Coverage 60.64% 60.39% -0.26%
+ Complexity 4913 4902 -11
============================================
Files 151 152 +1
Lines 34986 35134 +148
Branches 5849 5879 +30
============================================
Hits 21218 21218
- Misses 10927 11051 +124
- Partials 2841 2865 +24 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…ment-buffer-optimization
- Introduce BufferMode enum: HEAP, DIRECT_BUFFER, MEMORY_SEGMENT - Convert TDSPacket.payload from byte[] to ByteBuffer for zero-copy reads - Implement ByteBuffer.read() in TDSChannel for efficient I/O - Update TDSReader methods to use native ByteBuffer operations - Add automatic SSL-aware fallback (MEMORY_SEGMENT -> DIRECT_BUFFER) - Support legacy mssql.jdbc.useMemorySegment property
- Implement HEAP, DIRECT_BUFFER, and MEMORY_SEGMENT buffer modes - Add SSLEngine support for zero-copy I/O with TLS - Validated performance gains: READ 26-43% faster, WRITE 13-36% faster for binary - Smart fallback: MEMORY_SEGMENT -> DIRECT_BUFFER when SSL active
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.