-
Enhancement
-
Resolution: Fixed
-
P3
-
None
-
b37
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8083123 | emb-9 | Mikael Gerdin | P3 | Resolved | Fixed | b37 |
JDK-8065281 | 8u60 | Staffan Friberg | P3 | Closed | Won't Fix |
G1 requires pre and post barriers when writing references. They can under different circumstances be filtered to be avoided and the compiler is able to remove some of them and others are dynamically filtered during runtime to avoid doing the actual barrier.
For newly allocated objects it should be possible to avoid the barrier if it can be proven the reference write is the first write to the object and no safe point exists between the allocation and the write itself.
This pattern can for example be found in some objects where a reference is written to the object as part of the constructor, please look at the Node class in HashMap for a specific example.
A small microbenchmark trying to mimic the Node class allocation and write shows that it is possible to prove the barrier is not required in this case and performance gets closer to what the parallel GC is able to achieve in this case. See attached images for a graphical comparison, the 3 fields version is most similar to the Node class which has three fields being written.
For newly allocated objects it should be possible to avoid the barrier if it can be proven the reference write is the first write to the object and no safe point exists between the allocation and the write itself.
This pattern can for example be found in some objects where a reference is written to the object as part of the constructor, please look at the Node class in HashMap for a specific example.
A small microbenchmark trying to mimic the Node class allocation and write shows that it is possible to prove the barrier is not required in this case and performance gets closer to what the parallel GC is able to achieve in this case. See attached images for a graphical comparison, the 3 fields version is most similar to the Node class which has three fields being written.
- backported by
-
JDK-8083123 Avoid G1 write barriers on newly allocated objects
- Resolved
-
JDK-8065281 Avoid G1 write barriers on newly allocated objects
- Closed
- duplicates
-
JDK-7183509 G1 Impacting Performance of compiled code
- Closed