[foreign-memaccess+abi] RFR: 8311594: Avoid GlobalSession liveness check
Jorn Vernee
jvernee at openjdk.org
Fri Jul 7 20:05:47 UTC 2023
This patch overrides `checkValidStateRaw` in GlobalSession, to do nothing. The current `checkValidStateRaw` in MemorySessionImpl checks the owner thread, and liveness, which are both not needed for the global session.
Since the state field is mutable, I found that the JIT can not fold away the liveness check. This has a very marginal effect on performance, but since the fix is also very non-intrusive, I think it's okay to do.
I've added 2 new benchmarks that I've used to measure the difference. One measures the performance of MS::copy, and the other measures MS::get. Both use a special `ALL` segment which spans `0` to `Long.MAX_VALUE`, which means that the target address can be used as an offset when doing the accesses. This helps the bounds checks being eliminated, and makes the result of overriding `checkValidStateRaw` in GlobalSession easier to see.
Here are some of the interesting numbers:
Before:
Benchmark Mode Cnt Score Error Units
MemorySegmentCopyALL.panama_ALL_to_ALL avgt 30 7.788 ± 0.029 ns/op
MemorySegmentCopyALL.unsafe_array_to_addr avgt 30 7.543 ± 0.018 ns/op
Benchmark Mode Cnt Score Error Units
MemorySegmentGet.segment_ALL_unaligned avgt 30 0.486 ± 0.002 ns/op
MemorySegmentGet.unsafe avgt 30 0.398 ± 0.003 ns/op
After:
Benchmark Mode Cnt Score Error Units
MemorySegmentCopyALL.panama_ALL_to_ALL avgt 30 7.571 ± 0.017 ns/op
MemorySegmentCopyALL.unsafe_array_to_addr avgt 30 7.550 ± 0.019 ns/op
Benchmark Mode Cnt Score Error Units
MemorySegmentGet.segment_ALL_unaligned avgt 30 0.409 ± 0.002 ns/op
MemorySegmentGet.unsafe avgt 30 0.397 ± 0.003 ns/op
-------------
Commit messages:
- rename benchmark methods
- Drop Global Access Check
Changes: https://git.openjdk.org/panama-foreign/pull/844/files
Webrev: https://webrevs.openjdk.org/?repo=panama-foreign&pr=844&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8311594
Stats: 242 lines in 3 files changed: 242 ins; 0 del; 0 mod
Patch: https://git.openjdk.org/panama-foreign/pull/844.diff
Fetch: git fetch https://git.openjdk.org/panama-foreign.git pull/844/head:pull/844
PR: https://git.openjdk.org/panama-foreign/pull/844
More information about the panama-dev
mailing list