[foreign-memaccess+abi] RFR: Improve strlen performance [v4]
Maurizio Cimadamore
mcimadamore at openjdk.org
Tue Aug 15 12:15:26 UTC 2023
On Tue, 15 Aug 2023 10:21:41 GMT, Per Minborg <pminborg at openjdk.org> wrote:
>> This PR suggests removing the use of native calls for strlen and instead use Java implementations.
>>
>> The PR also suggest performance improvements for quad word strlen.
>>
>> Here are some benchmarks that compares the performance of the new proposed methods with the performance of the JDK 21 variants (called "legacy" methods):
>>
>> <img width="2596" alt="image" src="https://github.com/openjdk/panama-foreign/assets/7457876/c785f341-c826-4e3e-bf56-8387b1e96010">
>
> Per Minborg has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains ten commits:
>
> - Merge foreign-memaccess+abi and fix formatting
> - Fix missing spaces
> - Undo some unintended changes and clean up
> - Merge foreign-memaccess+abi
> - Clean up
> - Optimize str_len variants
> - Optimize strlen_short
> - Fix allocation size
> - Fix test with strcat
src/java.base/share/classes/jdk/internal/foreign/StringSupport.java line 123:
> 121:
> 122: // Handle the first unaligned "head" bytes separately
> 123: int headCount = (int)SharedUtils.remainsToAlignment(segment.address() + start, Long.BYTES);
This logic still seems to be tied to native segments. Heap segments have virtualized addresses, so this logic seems invalid. The best we can do, for heap segments, is to only use the better algo if we're using a long[] as an heap base (in which case the logic here would work reliably, and turn into aligned reads).
-------------
PR Review Comment: https://git.openjdk.org/panama-foreign/pull/862#discussion_r1294516900
More information about the panama-dev
mailing list