[foreign-memaccess+abi] RFR: Improve strlen performance [v10]

Maurizio Cimadamore mcimadamore at openjdk.org
Thu Aug 17 09:01:56 UTC 2023


On Thu, 17 Aug 2023 08:44:27 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 incrementally with one additional commit since the last revision:
> 
>   Clean up benchmark

Looks good - added few nitpick comments

src/java.base/share/classes/jdk/internal/foreign/StringSupport.java line 105:

> 103:      * <ul>
> 104:      *     <li>head (un-aligned access handling on a byte-by-byte basis) (if any)</li>
> 105:      *     <li>body (long aligned access handling eight bytes at a time) (if any)</li>

This and other comments in this class refer to alignment properties which I don't think are strictly valid. You might want to search for them and adjust them/remove them.

test/micro/org/openjdk/bench/java/lang/foreign/InternalStrLen.java line 87:

> 85: 
> 86:     @Benchmark
> 87:     public int legacySingleByte() {

I think we should rename `legacy` and `new` to something else. E.g. `byte` vs. `bulk`. You might rename the various methods as `byte_2` (meaning byte-by-byte, with two bytes chars).

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

Marked as reviewed by mcimadamore (Committer).

PR Review: https://git.openjdk.org/panama-foreign/pull/862#pullrequestreview-1582120367
PR Review Comment: https://git.openjdk.org/panama-foreign/pull/862#discussion_r1296898601
PR Review Comment: https://git.openjdk.org/panama-foreign/pull/862#discussion_r1296897408


More information about the panama-dev mailing list