RFR: 8339531: Improve performance of MemorySegment::mismatch [v9]
Maurizio Cimadamore
mcimadamore at openjdk.org
Thu Sep 5 18:00:53 UTC 2024
On Thu, 5 Sep 2024 17:47:16 GMT, Per Minborg <pminborg at openjdk.org> wrote:
>> This PR proposes to improve the performance of `MemorySegment::mismatch` by using Java code rather than transitioning to native code.
>
> Per Minborg has updated the pull request incrementally with one additional commit since the last revision:
>
> Fix errors in a benchmark
src/java.base/share/classes/jdk/internal/foreign/SegmentBulkOperations.java line 211:
> 209: final int s = SCOPED_MEMORY_ACCESS.getInt(src.sessionImpl(), src.unsafeGetBase(), src.unsafeGetOffset() + srcFromOffset + offset);
> 210: final int d = SCOPED_MEMORY_ACCESS.getInt(dst.sessionImpl(), dst.unsafeGetBase(), dst.unsafeGetOffset() + dstFromOffset + offset);
> 211: if (s != d) {
Can we run `mismatch(s, d)` and then check the returned index (e.g. `!= 0`) instead of doing a full comparison and then another mismatch? Or is that slower?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/20848#discussion_r1745954081
More information about the core-libs-dev
mailing list