[foreign-memaccess+abi] RFR: Add test for resource scope acquire with bulk operation
Chris Hegarty
chegar at openjdk.java.net
Wed Apr 14 13:53:44 UTC 2021
On Wed, 14 Apr 2021 13:36:58 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
> This patch adds a test for a bulk segment mismatch inside an acquire block. This benchmark measures the relative overhead of the acquier operation, relative to the cost of the bulk mismatch. Results for large segments are as follows:
>
>
> Benchmark (scopeKind) Mode Cnt Score Error Units
> BulkMismatchAcquire.mismatch_large_segment CONFINED avgt 30 37662.474 ? 579.201 ns/op
> BulkMismatchAcquire.mismatch_large_segment SHARED avgt 30 37583.186 ? 427.663 ns/op
> BulkMismatchAcquire.mismatch_large_segment IMPLICIT avgt 30 37577.151 ? 474.734 ns/op
> BulkMismatchAcquire.mismatch_large_segment_acquire CONFINED avgt 30 37801.227 ? 515.459 ns/op
> BulkMismatchAcquire.mismatch_large_segment_acquire SHARED avgt 30 37159.676 ? 369.788 ns/op
> BulkMismatchAcquire.mismatch_large_segment_acquire IMPLICIT avgt 30 37854.949 ? 464.150 ns/op
>
>
> Here, we can see that the cost of the acquire is, in all cases, negligible, compared with the cost of the underlying bulk operation. We expect this to be the use case where resource scope handles are used the most.
>
> For completeness, here's the same benchmark, but with a smaller segment size:
>
>
> Benchmark (scopeKind) Mode Cnt Score Error Units
> BulkMismatchAcquire.mismatch_small_segment CONFINED avgt 30 5.826 ? 0.091 ns/op
> BulkMismatchAcquire.mismatch_small_segment SHARED avgt 30 5.160 ? 0.072 ns/op
> BulkMismatchAcquire.mismatch_small_segment IMPLICIT avgt 30 5.274 ? 0.090 ns/op
> BulkMismatchAcquire.mismatch_small_segment_acquire CONFINED avgt 30 7.386 ? 0.035 ns/op
> BulkMismatchAcquire.mismatch_small_segment_acquire SHARED avgt 30 15.130 ? 0.649 ns/op
> BulkMismatchAcquire.mismatch_small_segment_acquire IMPLICIT avgt 30 6.877 ? 0.083 ns/op
>
>
> In this case, we see that for implicit and confined scope the cost is low; for shared segments we have a spike (which is related to the CAS logic in the shared handle). We believe this to be an acceptable compromise, and an unavoidable consequence of having true, deterministic shared segments.
>
> In addition to adding the benchmark - the patch also does two other things:
>
> * Fixes a bug in the NonCloseableScope::acquire logic (the polarity of the null check is wrong, and this was causing NPEs on the benchmark - whoops)
> * Fixes the unrelated test issue with SpliteratorTest - this was also fixed by PR/494, but seeing that it's not converging, I'd like to get the tests fixed sooner rather than later
LGTM. ( I happened to noticed the polarity of the null check was wrong too, but you got to it before me :-) )
-------------
Marked as reviewed by chegar (Committer).
PR: https://git.openjdk.java.net/panama-foreign/pull/503
More information about the panama-dev
mailing list