Performance impact of *_UNALIGNED when segment is aligned.
Lee Rhodes
leerho at gmail.com
Thu May 15 16:55:23 UTC 2025
The DataSketches library can be handed segments from other applications and
cannot guarantee the underlying memory alignment of these segments and it
would be too burdensome to require a specific alignment. As I result, the
library will have to always use *_UNALIGNED layouts when accessing these
segments.
>From the Javadocs I understand that there can be a performance impact
accessing *_UNALIGNED values in a segment that is not appropriately
aligned. For example, accessing JAVA_LONG values in a
MemorySegment.ofArray(byte[]). This leads me to a couple of questions
related to performance and alignment that don't seem to be answered in the
documentation:
- Is there a performance impact of using *_UNALIGNED layouts on segments
that are fortuitously properly aligned, instead of being configured with
the proper alignment?
- Is the performance of underlying vector operations used on segment
bulk operations impacted by alignment? For example, are the vector
operations disabled if the segment alignment doesn't match an array element
natural alignment? Or are they just slower?
Lee.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/panama-dev/attachments/20250515/3354c373/attachment.htm>
More information about the panama-dev
mailing list