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

Maurizio Cimadamore mcimadamore at openjdk.org
Tue Aug 15 15:21:26 UTC 2023


On Tue, 15 Aug 2023 14:40:55 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:
> 
>   Allow heap segments of Long and Double to use chunked len calc

test/jdk/java/foreign/TestStringEncoding.java line 484:

> 482:         @Override
> 483:         public MemorySegment allocate(long byteSize, long byteAlignment) {
> 484:             var seg = switch (type) {

Technically speaking, this is not an arena - as all returned segments have disjoint scopes. That said, you can try to create an heap-based arena using a slicing allocator? E.g. have HeapArena take a Java array - then wrap the array into a segment in the constructor, and wrap that segment into a SegmentAllocator. The Arena scope now is the scope of the heap segment. The close operation can be a no-op.

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

PR Review Comment: https://git.openjdk.org/panama-foreign/pull/862#discussion_r1294755058


More information about the panama-dev mailing list