-
Couldn't load subscription status.
- Fork 2.3k
Closed
Labels
Search:PerformanceenhancementEnhancement or improvement to existing feature or requestEnhancement or improvement to existing feature or request
Description
Is your feature request related to a problem? Please describe
Currently, all source data in search hits is converted using:
hitBuilder.setSource(ByteString.copyFrom(
bytesRef.bytes, bytesRef.offset, bytesRef.length));This approach creates a defensive copy of the underlying byte array for every search hit, regardless of the source type.
Describe the solution you'd like
Implement a zero-copy optimization that:
- Detects
BytesArrayinstances - The most commonBytesReferenceimplementation in OpenSearch - Uses
UnsafeByteOperations.unsafeWrap()- Avoids memory copying for immutable data - Maintains backward compatibility - Falls back to defensive copying for other implementations
Related component
Search:Performance
Describe alternatives you've considered
No response
Additional context
Expected performance benefits include:
- Lower serialization latency: especially for large documents
- Improved throughput: Better performance under high search loads
- Memory allocation reduction: reduction from
BytesArraysources - Reduced garbage collection pressure: Fewer temporary objects created
Metadata
Metadata
Assignees
Labels
Search:PerformanceenhancementEnhancement or improvement to existing feature or requestEnhancement or improvement to existing feature or request
Type
Projects
Status
✅ Done
Status
Done/Won't Do