[foreign-memaccess+abi] RFR: Add support for high-level functions to copy to and from Java arrays

Uwe Schindler uschindler at openjdk.java.net
Mon Jun 21 15:32:53 UTC 2021


On Mon, 21 Jun 2021 15:21:43 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

> > Hi,
> > when testing this with Lucene, Irecognized the following:
> > ```
> > org.apache.lucene.store.TestMultiMMap > test suite's output saved to /home/thetaphi/benchmark/lucene_candidate/lucene/core/build/test-results/test/outputs/OUTPUT-org.apache.lucene.store.TestMultiMMap.txt, copied below:
> >    >     java.lang.IllegalArgumentException: Source segment incompatible with alignment constraints
> >    >         at __randomizedtesting.SeedInfo.seed([90A99875BABA30A6:B162CD10DB95DFC]:0)
> >    >         at jdk.incubator.foreign/jdk.internal.foreign.AbstractMemorySegmentImpl.copyFrom(AbstractMemorySegmentImpl.java:158)
> >    >         at jdk.incubator.foreign/jdk.incubator.foreign.MemoryCopy.copyToArray(MemoryCopy.java:493)
> >    >         at org.apache.lucene.store.MemorySegmentIndexInput.readLongs(MemorySegmentIndexInput.java:204)
> > ```
> > 
> > 
> >     
> >       
> >     
> > 
> >       
> >     
> > 
> >     
> >   
> > So it is impossible to copy stuff if the source segment is not at an aligned position. Unfortunately, with data inside a memory mapped file it may often happen that data is not properly aligned, but you still need to copy them (including swapping).
> 
> This is an issue in the layouts used by the MemoryCopy class. I meant to drop all alignment constraints from them when doing another pass on the code, but it seems like I forgot.

No problem, I just commented out the long/float methods and the tests were passing. I am now benchmarking, but again it looks not so well with the garbage created... (see #560). But I have to wait for the benchmark to finish.

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

PR: https://git.openjdk.java.net/panama-foreign/pull/555


More information about the panama-dev mailing list