Details
-
Enhancement
-
Resolution: Fixed
-
P4
-
8, 11, 13
-
b24
Backports
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8225869 | 14 | Sergey Kuksenko | P4 | Resolved | Fixed | team |
JDK-8263237 | 11.0.12 | Sergey Kuksenko | P4 | Resolved | Fixed | b01 |
Description
If forall loop is used for traversing big enough collection C2 doesn't inline the iterator() method. That is caused by MinInliningThreshold option. iterator() is invoked in loop prolog and for enough number of iterations loop prolog is considered as cold code in comparison to the loop body. Practical boundary is approximately 1500 elements of collection. For smaller collections iterator() is inlined, for larger collection - not inlined.
The fact that iterator() method is not inlined leads to not performed scalar replacement for the Iterator object. Allocation cost of the single Iterator object traversing large enough collections is negligible. However, if Iterator state has reverences (which are updated on each step), GC write barriers are invoked and GC barriers have a large cost to iteration. When Iterator object is scalarized - no need for GC barriers invocation.
Other part of discussion is here http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/2019-February/032623.html
Microbenchmarks targeting that for different collections could be found here http://cr.openjdk.java.net/~skuksenko/hotspot/8223504/benchmark/
The fact that iterator() method is not inlined leads to not performed scalar replacement for the Iterator object. Allocation cost of the single Iterator object traversing large enough collections is negligible. However, if Iterator state has reverences (which are updated on each step), GC write barriers are invoked and GC barriers have a large cost to iteration. When Iterator object is scalarized - no need for GC barriers invocation.
Other part of discussion is here http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/2019-February/032623.html
Microbenchmarks targeting that for different collections could be found here http://cr.openjdk.java.net/~skuksenko/hotspot/8223504/benchmark/
Attachments
Issue Links
- backported by
-
JDK-8225869 improve performance of forall loops by better inlining of "iterator()" methods.
- Resolved
-
JDK-8263237 improve performance of forall loops by better inlining of "iterator()" methods.
- Resolved
- relates to
-
JDK-8227236 assert(singleton != __null && singleton != declared_interface) failed
- Resolved