MemoryLayout api
forax at univ-mlv.fr
forax at univ-mlv.fr
Tue Jan 21 18:03:41 UTC 2020
----- Mail original -----
> De: "Maurizio Cimadamore" <maurizio.cimadamore at oracle.com>
> À: "Remi Forax" <forax at univ-mlv.fr>, "panama-dev at openjdk.java.net'" <panama-dev at openjdk.java.net>
> Envoyé: Mardi 21 Janvier 2020 18:36:10
> Objet: Re: MemoryLayout api
> On 21/01/2020 15:17, Remi Forax wrote:
>> Hi all,
>> i've played a little bit with the current version used by the jdk 15 and the one
>> in the branch foreign-memaccess (for the benchmarks).
>>
>> I really like the API, the MemoryLayout part in particular.
>>
>> I will do a presentation in two weeks about the foreign API (and everythings
>> else introduced in jdk 14)
>> https://github.com/forax/do-synthetic-methods-dream-of-electric-switch-expressions
>> All my tests are available as a python notebook (see the README).
>
> Nice tests :-)
>
> I'm happy that you are getting relatively decent numbers, considering
> the number of C2 potholes we are currently working around.
if you stay away from MemoryAddress.offset/addOffset(), yes !
>
> One question - do all your ByteBuffer benchmarks use Unsafe.invokeCleaner() ?
The tests marked "Creation + loop" do allocation + loop + de-allocation,
They measure the whole cost. For thoses i use Unsafe.invokeCleaner() [1].
The tests marked "Loop only, constant memory" do not do allocation in the test but in a static block [2] and there is no deallocation.
They only measure the cost of the loop when the MemoryAddress/ByteBuffer/long is constant.
This is the cost i'm most interested in with my hat of writer of a dynamic language runtime.
>
>
> Maurizio
Rémi
[1] https://github.com/forax/panama-foreign/blob/master/src/test/java/fr.umlv.foreign/fr/umlv/foreign/ReadMemoryBenchMark.java#L70
[2] https://github.com/forax/panama-foreign/blob/master/src/test/java/fr.umlv.foreign/fr/umlv/foreign/ReadGlobalMemoryBenchMark.java#L64
>
>
>>
>> There is something i don't understand.
>> The memory layout API let you create layouts that are invalid, i.e. that you can
>> not create any VarHandle on it,
>> by example a group (struct or union) that contains a sequence without a size, or
>> a layout that starts with two sequences with no size.
>>
>> I get why you can have one sequence free, but you can not have more than one,
>> otherwise you can not compute the size of the inner layout.
>>
>> So why the layout API let users create such badly shaped layout ?
>> May i have overlooked something ?
>>
>> regards,
>> Rémi
>>
More information about the panama-dev
mailing list