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

Per Minborg pminborg at openjdk.org
Wed Aug 28 11:10:05 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/ee29fdf0-a7cf-4d5b-bb6b-278b01d97e3c)
> 
> 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 incrementally with one additional commit since the last revision:

  Make minor updates after comments

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/20712/files
  - new: https://git.openjdk.org/jdk/pull/20712/files/e2a52912..78eb92a6

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

  Stats: 9 lines in 2 files changed: 2 ins; 6 del; 1 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