[foreign-memaccess+abi] RFR: Improve strlen performance [v4]
Per Minborg
pminborg at openjdk.org
Tue Aug 15 13:18:25 UTC 2023
On Tue, 15 Aug 2023 12:16:17 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
>> 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 268:
>
>> 266: // Do an initial read using aligned semantics.
>> 267: // If this succeeds, we know that all other subsequent reads will be aligned
>> 268: if (segment.get(JAVA_INT, start) == 0) {
>
> I would expect a simple loop here? What's the deal with avoiding alignment? If that's to speed up by avoiding alignment checks, it should not be required, as the segment being accessed is always at the same base address and the alignment check should be hoisted.
The proposed solution retains the same semantics as the old method where we would get an alignment error if presented with an unaligned MS (e.g. `alignedSegment.asSlice(1)`) but with improved performance (see the benchmarks at the top).
-------------
PR Review Comment: https://git.openjdk.org/panama-foreign/pull/862#discussion_r1294583026
More information about the panama-dev
mailing list