-
Enhancement
-
Resolution: Unresolved
-
P5
-
None
-
None
-
generic
-
generic
ADDITIONAL SYSTEM INFORMATION :
JDK23 EA, all platforms.
A DESCRIPTION OF THE PROBLEM :
Please consider providing a performance optimized method of filling a subsection of MemorySegment with a byte, with a signature such as:
MemorySegment.fill(long offset, long length, byte b);
Currently there is only MemorySegment.fill(byte b) that fills a whole MemorySegment. The only ways I can find to fill a subsection of a MemorySegment are:
1) Call MemorySegment.set(ValueLayout.JAVA_BYTE, long offset , byte v); in a loop incurring a bounds check on every call
2) Slice the original MemorySegment using MemorySegment.asSlice(long offset, long newSize) followed by MemorySegment.fill(byte b) on the new segment, incurring the overhead of object creation and cleanup.
Justification:
1) We need the ability to fill a subsection of a MemorySegment with the absolute highest performance
2) The MemorySegment.copy() methods allow a subsection of a one segment to be copied to another. The omission of a way to fill a subsection of a segment sees inconsistent.
3) We are attempting to replace code that currently uses sun.misc.Unsafe. Unsafe.setMemory(long address, long length, byte b), which is now deprecated. Unsafe.setMemory() is highly performant - I believe it is a HotSpot intrinsic.
JDK23 EA, all platforms.
A DESCRIPTION OF THE PROBLEM :
Please consider providing a performance optimized method of filling a subsection of MemorySegment with a byte, with a signature such as:
MemorySegment.fill(long offset, long length, byte b);
Currently there is only MemorySegment.fill(byte b) that fills a whole MemorySegment. The only ways I can find to fill a subsection of a MemorySegment are:
1) Call MemorySegment.set(ValueLayout.JAVA_BYTE, long offset , byte v); in a loop incurring a bounds check on every call
2) Slice the original MemorySegment using MemorySegment.asSlice(long offset, long newSize) followed by MemorySegment.fill(byte b) on the new segment, incurring the overhead of object creation and cleanup.
Justification:
1) We need the ability to fill a subsection of a MemorySegment with the absolute highest performance
2) The MemorySegment.copy() methods allow a subsection of a one segment to be copied to another. The omission of a way to fill a subsection of a segment sees inconsistent.
3) We are attempting to replace code that currently uses sun.misc.Unsafe. Unsafe.setMemory(long address, long length, byte b), which is now deprecated. Unsafe.setMemory() is highly performant - I believe it is a HotSpot intrinsic.