On Thu, 31 Oct 2024 17:23:51 GMT, Quan Anh Mai <qa...@openjdk.org> wrote:
>> Hi, >> >> This patch makes `MemorySessionImpl.state` a `Stable` field so that liveness >> check of non-closeable scopes such as the global scope can be elided. >> >> Currently, the `state` field is overloaded with 2 responsibilities, to act >> as a communication device between `close` and `checkValidState`, as well as >> a communication device between `close`, `acquire`, and `release`. This patch >> separates those concerns into `state` and `acquireCount`, allowing `state` >> to be marked as `@Stable`. >> >> With the patch, in `MemorySegmentGetUnsafe`, `panama` is able to be on par >> with `unsafe`: >> >> Benchmark Mode Cnt Score Error Units >> MemorySegmentGetUnsafe.panama avgt 30 0.340 ± 0.008 ns/op >> MemorySegmentGetUnsafe.unsafe avgt 30 0.332 ± 0.004 ns/op >> >> For reference this is the results without this patch: >> >> Benchmark Mode Cnt Score Error Units >> MemorySegmentGetUnsafe.panama avgt 30 0.420 ± 0.019 ns/op >> MemorySegmentGetUnsafe.unsafe avgt 30 0.329 ± 0.003 ns/op >> >> Please kindly review, thanks very much. > > Quan Anh Mai has updated the pull request incrementally with one additional > commit since the last revision: > > add LoopOverRandom benchmarks The result of the new benchmark by @mcimadamore , the patch offers an improvement in the `segment_loop_all` and `segment_loop_asUnchecked` cases. For some reasons, the compiler really dislikes the unsafe loop. Before After Benchmark Mode Cnt Score Error Score Error Units LoopOverRandom.segment_loop avgt 30 2.218 ± 0.007 2.261 ± 0.096 us/op LoopOverRandom.segment_loop_all avgt 30 1.958 ± 0.007 1.917 ± 0.005 us/op LoopOverRandom.segment_loop_asUnchecked avgt 30 1.834 ± 0.005 1.747 ± 0.004 us/op LoopOverRandom.unsafe_loop avgt 30 1.825 ± 0.026 1.795 ± 0.004 us/op ------------- PR Comment: https://git.openjdk.org/jdk/pull/21810#issuecomment-2450429727