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

Per Minborg pminborg at openjdk.org
Mon Sep 2 08:56:20 UTC 2024


On Fri, 30 Aug 2024 10:51:59 GMT, Per Minborg <pminborg at openjdk.org> wrote:

>> 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/87e837b6-30e4-4299-a9a1-14776e575825)
>> 
>> 
>> 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 two additional commits since the last revision:
> 
>  - Revert copyright year
>  - Move logic back to AMSI

Here is the performance improvement for Linux a64. Looks like a significant improvement.

![image](https://github.com/user-attachments/assets/43d7e07b-775f-4382-8aa1-3893dfe635a6)

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

PR Comment: https://git.openjdk.org/jdk/pull/20712#issuecomment-2324186401


More information about the core-libs-dev mailing list