RFR: 8338591: Improve performance of MemorySegment::copy
Per Minborg
pminborg at openjdk.org
Tue Sep 3 08:17:48 UTC 2024
This PR proposes to handle smaller FFM copy operations with Java code rather than transitioning to native code. This will improve performance. In this PR, copy operations involving zero to 63 bytes will be handled by Java code.
Here is what it looks like for Windows x64:

Here is another chart for Linux a64:

Other platforms exhibit similar behavior. It should be noted that the gain with this PR is pronounced for certain common sizes that are more likely to appear in code (e.g. 8, 16, 24, and 32)
It would be possible to use the same code path for the 7arg `MemorySegment::copy` method if it is similar to:
MemorySegment.copy(heapSrcSegment, JAVA_BYTE, 0, heapDstSegment, JAVA_BYTE, 0, ELEM_SIZE);
This could be added in a separate PR.
-------------
Commit messages:
- Fix copyright years
- Clean up
- Increase threshhold to 64 bytes
- Merge branch 'master' into copy-performance
- Merge branch 'master' into mismatch-performance
- Only handle disjunct mem copy
- Add implementation
- Improve benchmarks
- Fix bugs
- Add prototypes
Changes: https://git.openjdk.org/jdk/pull/20829/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=20829&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8338591
Stats: 299 lines in 4 files changed: 286 ins; 6 del; 7 mod
Patch: https://git.openjdk.org/jdk/pull/20829.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/20829/head:pull/20829
PR: https://git.openjdk.org/jdk/pull/20829
More information about the core-libs-dev
mailing list