Skip to content

Bulk-copy byte fields on the read path - #859

Open
DanielThomas wants to merge 5 commits into
dannyt/immutable-shard-iteratorsfrom
dannyt/bulk-byte-field-reads
Open

DanielThomas wants to merge 5 commits into
dannyt/immutable-shard-iteratorsfrom
dannyt/bulk-byte-field-reads

Conversation

@DanielThomas

@DanielThomas DanielThomas commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

HollowObjectTypeReadStateShard.readBytes() currently materializes a BYTES field by calling ByteData.get() for every byte. For segmented on-heap data, each call repeats interface dispatch, segment lookup, and offset masking.

Add ByteData.copyTo(...) and use it to materialize byte fields in bulk:

  • SegmentedByteArray copies one contiguous segment range at a time with System.arraycopy.
  • ArrayByteData uses System.arraycopy directly.
  • EncodedByteBuffer copies chunks from duplicated mapped buffers, preserving thread-safe reads.
  • Other ByteData implementations retain a byte-by-byte default.

Benchmark

JMH on Java 8/x86-64. Each invocation includes allocation of the returned byte array. The source begins 17 bytes before a segment boundary, so values of 32 bytes and larger cross at least one boundary.

Field size Per-byte copy Bulk copy Improvement
8 bytes 15.850 ns 12.818 ns 19.1%
32 bytes 38.981 ns 20.132 ns 48.4%
256 bytes 247.829 ns 36.113 ns 85.4%
2,048 bytes 2,023.069 ns 129.415 ns 93.6%

On Java 25 on the same host, the corresponding improvements were 34.3%, 64.7%, 91.9%, and 95.3%.

@DanielThomas
DanielThomas force-pushed the dannyt/bulk-byte-field-reads branch 2 times, most recently from b8fef45 to 6fcc882 Compare September 23, 2026 03:21
@DanielThomas
DanielThomas added this pull request to stack #857 September 23, 2026 03:37
@DanielThomas
DanielThomas marked this pull request as ready for review September 23, 2026 03:54
@DanielThomas
DanielThomas force-pushed the dannyt/bulk-byte-field-reads branch from 6fcc882 to 106e7d9 Compare September 23, 2026 04:15
@DanielThomas
DanielThomas force-pushed the dannyt/bulk-byte-field-reads branch from 106e7d9 to ef404e8 Compare September 23, 2026 06:41
@DanielThomas
DanielThomas force-pushed the dannyt/bulk-byte-field-reads branch from ef404e8 to 5832ed8 Compare September 26, 2026 02:20
Comment thread hollow/src/main/java/com/netflix/hollow/core/memory/encoding/BlobByteBuffer.java Outdated
@DanielThomas
DanielThomas force-pushed the dannyt/bulk-byte-field-reads branch 2 times, most recently from 4b1f582 to f5cf646 Compare October 6, 2026 04:06
@DanielThomas
DanielThomas force-pushed the dannyt/bulk-byte-field-reads branch from f5cf646 to 257b31e Compare October 7, 2026 02:48
@DanielThomas

Copy link
Copy Markdown
Member Author

Gated bulk byte-field copies behind SHARD_READ_FAST_PATHS. Empty/null byte-field fixes remain unconditional.

@DanielThomas
DanielThomas force-pushed the dannyt/bulk-byte-field-reads branch from 257b31e to 62a75fb Compare October 7, 2026 02:54
Add a ByteData range-copy operation with segment-aware on-heap and mapped-buffer implementations. Use it when materializing BYTES fields instead of resolving storage one byte at a time.

Preserve the existing read validation and retry protocol, and cover segment and mapped-buffer boundaries with on-heap and shared-memory round trips.
DanielThomas and others added 2 commits October 7, 2026 14:02
Document allocating and reusable benchmark variants and shared-buffer read safety.

Co-authored-by: Jason Koch <jkoch@netflix.com>
@DanielThomas
DanielThomas force-pushed the dannyt/bulk-byte-field-reads branch from 62a75fb to 5555731 Compare October 7, 2026 03:02

This branch has not been deployed

No deployments
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.

3 participants