[foreign-memaccess+abi] RFR: Add support for high-level functions to copy to and from Java arrays [v2]
Maurizio Cimadamore
mcimadamore at openjdk.java.net
Mon Jun 21 16:55:49 UTC 2021
On Mon, 21 Jun 2021 16:20:56 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
> > I don't want to post too much in this issue as it is not fully related, but it looks this is also affected by the same garbage problem described in https://bugs.openjdk.java.net/browse/JDK-8268743:
> > ```
> > PROFILE SUMMARY from 14119950 events (total: 4897631M)
> > tests.profile.mode=heap
> > tests.profile.count=30
> > tests.profile.stacksize=1
> > tests.profile.linenumbers=false
> > PERCENT HEAP SAMPLES STACK
> > 49.63% 2430891M jdk.internal.foreign.MappedMemorySegmentImpl#dup()
> > 28.37% 1389691M jdk.internal.foreign.HeapMemorySegmentImpl$OfByte#fromArray()
> > 21.43% 1049362M jdk.internal.foreign.HeapMemorySegmentImpl$OfByte#dup()
> > 0.09% 4624M org.apache.lucene.util.FixedBitSet#<init>()
> > ```
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > See the number of heap samples, this cannot be! The only difference to the JFR heap profile in https://bugs.openjdk.java.net/browse/JDK-8268743 is the order (here we have more dups of the MappedMemorySegment (source from where it is copied).
>
> This is strange. All the copy methods are now forced inlined, so I can't understand why you would observe allocation coming from there (I would expect C2 to just optimize that method regardless of its context). The only thing left for you to try is this:
>
> https://github.com/mcimadamore/panama-foreign/tree/small_copy_benchmark/
>
> Which contains a static method `copy` in MemorySegment which takes offsets. This method avoids the slices (but you would still need to wrap arrays) - it would be interesting to see if the allocation profile on Lucene changes at all.
Also, would it be possible for you to check if the methods in MemoryCopy are compiled at all? `@ForceInline` won't do much if the method that caller is not compiled, it seems.
-------------
PR: https://git.openjdk.java.net/panama-foreign/pull/555
More information about the panama-dev
mailing list