Add benchmark to measure performance of VH adapters #175
Conversation
|
With the adapter creating IntBox, this benchmark is also testing whether C2 can eliminate the allocation of the box. If the goal is to measure an adapted VarHandle against a non-adapted baseline VarHandle, I think it makes sense to have the adapters be the identity function, since then the only difference is whether an adapter is present or not. WDYT? |
I guess my (non stated) goal was to benchmark non trivial adaptation where users could create their own carriers on top of the foreign memory access API. I wanted to make sure that the VH machinery didn't add extra cost when doing so. |
Looks good |
@mcimadamore This change now passes all automated pre-integration checks, type
Since the source branch of this PR was last updated there has been 1 commit pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid automatic rebasing, please merge
|
/integrate |
@mcimadamore The following commits have been pushed to foreign-memaccess since your change was applied:
Your commit was automatically rebased without conflicts. Pushed as commit e2d2dba. |
This patch adds a straightforward benchmark to measure performances of var handle adapters.
The benchmark is set up to read values from an int array, both with a var handle(obtained from
MethodHandles
), an associatedMethodHandle
(derived from the first var handle) and with a segment-based, memory access var handle.Then the same test is repeated, but with an extra adaptation step inserted in the middle - rather than reading
int
values directly, the adapter turnsints
into instances of
IntBox
and the loop code doing the sum converts them back into ints.Numbers are extremeluy solid on my machine:
I thought it would have been nice to add this to our benchmark suites since we do not have anything that tests VH adaptation directly.
Progress
Reviewers
Download
$ git fetch https://git.openjdk.java.net/panama-foreign pull/175/head:pull/175
$ git checkout pull/175