[jdk18] RFR: 8279930: Synthetic cast causes generation of store barriers when using heap segments [v2]

Maurizio Cimadamore mcimadamore at openjdk.java.net
Thu Jan 13 12:26:17 UTC 2022


> When looking at larger benchmarks, I noted a discrepancy between the performance of off-heap segments and on-heap segments. Looking at the assembly for the `MemorySegment::asSlice` method I could see some additional barriers in the off-heap case, but could not initially make sense of them. Vlad pointed me at G1 (in fact no such barrier was emitted when using a different GC, such as the serial GC, or ZGC), and later Erik narrowed the problem down to a failure in a C2 optimization to remove barriers around initializing stores. This problem was caused by a synthetic cast added by javac to a value (the base object) that initialized the newly created memory segment slice. Because of that case, C2 missed the store as an "initializing" one, and inserted additional barriers. This patch should make performance of on-heap segments a lot more reliable, especially when slicing is involved.

Maurizio Cimadamore has updated the pull request incrementally with one additional commit since the last revision:

  Add toplevel javadoc rationale in HeapMemorySegmentImpl

-------------

Changes:
  - all: https://git.openjdk.java.net/jdk18/pull/97/files
  - new: https://git.openjdk.java.net/jdk18/pull/97/files/9ef83f53..af8fb319

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk18&pr=97&range=01
 - incr: https://webrevs.openjdk.java.net/?repo=jdk18&pr=97&range=00-01

  Stats: 6 lines in 1 file changed: 4 ins; 0 del; 2 mod
  Patch: https://git.openjdk.java.net/jdk18/pull/97.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk18 pull/97/head:pull/97

PR: https://git.openjdk.java.net/jdk18/pull/97


More information about the core-libs-dev mailing list