RFR: 8338967: Improve performance for MemorySegment::fill [v5]

Per Minborg pminborg at openjdk.org
Tue Aug 27 10:38:46 UTC 2024


> The performance of the `MemorySegment::fil` can be improved by replacing the `checkAccess()` method call with calling `checkReadOnly()` instead (as the bounds of the segment itself do not need to be checked).
> 
> Also, smaller segments can be handled directly by Java code rather than transitioning to native code.
> 
> Here is how the `MemorySegment::fill` performance is improved by this PR:
> 
> ![image](https://github.com/user-attachments/assets/92a0bcf2-f5b0-4a91-9c02-39423f870209)
> 
> Operations involving 8 or more bytes are delegated to native code whereas smaller segments are handled via a switch rake.
> 
> It should be noted that `Arena::allocate` is using `MemorySegment::fil`. Hence, this PR will also have a positive effect on memory allocation performance.

Per Minborg has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains six additional commits since the last revision:

 - Merge branch 'master' into fill-performance
 - Fix typo
 - Add a comment about the old switch type
 - Remove unused import
 - Reduce kick-in size and add test
 - Initial implementation

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/20712/files
  - new: https://git.openjdk.org/jdk/pull/20712/files/b28f97fa..6fb6eefa

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=20712&range=04
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=20712&range=03-04

  Stats: 1722 lines in 197 files changed: 1151 ins; 181 del; 390 mod
  Patch: https://git.openjdk.org/jdk/pull/20712.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/20712/head:pull/20712

PR: https://git.openjdk.org/jdk/pull/20712


More information about the core-libs-dev mailing list