On Thu, 8 Oct 2020 23:17:33 GMT, Paul Sandoz <psan...@openjdk.org> wrote:

>> Maurizio Cimadamore has updated the pull request incrementally with one 
>> additional commit since the last revision:
>> 
>>   Fix indent in GensrcScopedMemoryAccess.gmk
>
> Reviewed this when updated in 
> [panama-foreign](https://github.com/openjdk/panama-foreign/tree/foreign-memaccess),
>  hence
> the lack of substantial comments for this PR.

When re-running all benchmarks, I noted an issue with the `BulkOps` 
microbenchmark: calling `MemorySegment::mismatch`
on a small segment (< 8 bytes) was 10x slower than with ByteBuffers. After some 
investigation, I realized that the
issue is caused by the fact that the `AbstractMemorySegmentImpl::mismatch` 
method contains inexact var handle calls,
where the segment coordinate has type `AbstractMemorySegmentImpl` instead of 
the expected `MemorySegment`, so we take
the slow path.

A simple solution is to avoid using var handles directly here, and use the 
helper functions in MemoryAccess, which
widens the type accordingly and produce an exact var handle call.

With this change, perfomance of mismatch on small segment is on par with 
ByteBuffer.

-------------

PR: https://git.openjdk.java.net/jdk/pull/548

Reply via email to