Tue, 10 Dec 2013 10:31:00 +0100
8028993: Full collections with ParallelScavenge slower in JDK 8 compared to 7u40
Summary: Reducing the number of calls to follow_class_loader to speed up the marking phase. Also removed some unnecessary calls to adjust_klass.
Reviewed-by: stefank, jmasa, mgerdin
1.1 --- a/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp Mon Dec 09 08:20:45 2013 +0100 1.2 +++ b/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp Tue Dec 10 10:31:00 2013 +0100 1.3 @@ -2433,20 +2433,6 @@ 1.4 _gc_tracer.report_object_count_after_gc(is_alive_closure()); 1.5 } 1.6 1.7 -void PSParallelCompact::follow_klass(ParCompactionManager* cm, Klass* klass) { 1.8 - ClassLoaderData* cld = klass->class_loader_data(); 1.9 - // The actual processing of the klass is done when we 1.10 - // traverse the list of Klasses in the class loader data. 1.11 - PSParallelCompact::follow_class_loader(cm, cld); 1.12 -} 1.13 - 1.14 -void PSParallelCompact::adjust_klass(ParCompactionManager* cm, Klass* klass) { 1.15 - ClassLoaderData* cld = klass->class_loader_data(); 1.16 - // The actual processing of the klass is done when we 1.17 - // traverse the list of Klasses in the class loader data. 1.18 - PSParallelCompact::adjust_class_loader(cm, cld); 1.19 -} 1.20 - 1.21 void PSParallelCompact::follow_class_loader(ParCompactionManager* cm, 1.22 ClassLoaderData* cld) { 1.23 PSParallelCompact::MarkAndPushClosure mark_and_push_closure(cm); 1.24 @@ -2455,13 +2441,6 @@ 1.25 cld->oops_do(&mark_and_push_closure, &follow_klass_closure, true); 1.26 } 1.27 1.28 -void PSParallelCompact::adjust_class_loader(ParCompactionManager* cm, 1.29 - ClassLoaderData* cld) { 1.30 - cld->oops_do(PSParallelCompact::adjust_pointer_closure(), 1.31 - PSParallelCompact::adjust_klass_closure(), 1.32 - true); 1.33 -} 1.34 - 1.35 // This should be moved to the shared markSweep code! 1.36 class PSAlwaysTrueClosure: public BoolObjectClosure { 1.37 public:
2.1 --- a/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.hpp Mon Dec 09 08:20:45 2013 +0100 2.2 +++ b/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.hpp Tue Dec 10 10:31:00 2013 +0100 2.3 @@ -1200,13 +1200,10 @@ 2.4 T* p); 2.5 template <class T> static inline void adjust_pointer(T* p); 2.6 2.7 - static void follow_klass(ParCompactionManager* cm, Klass* klass); 2.8 - static void adjust_klass(ParCompactionManager* cm, Klass* klass); 2.9 + static inline void follow_klass(ParCompactionManager* cm, Klass* klass); 2.10 2.11 static void follow_class_loader(ParCompactionManager* cm, 2.12 ClassLoaderData* klass); 2.13 - static void adjust_class_loader(ParCompactionManager* cm, 2.14 - ClassLoaderData* klass); 2.15 2.16 // Compaction support. 2.17 // Return true if p is in the range [beg_addr, end_addr). 2.18 @@ -1380,6 +1377,11 @@ 2.19 } 2.20 } 2.21 2.22 +inline void PSParallelCompact::follow_klass(ParCompactionManager* cm, Klass* klass) { 2.23 + oop holder = klass->klass_holder(); 2.24 + PSParallelCompact::mark_and_push(cm, &holder); 2.25 +} 2.26 + 2.27 template <class T> 2.28 inline void PSParallelCompact::KeepAliveClosure::do_oop_work(T* p) { 2.29 mark_and_push(_compaction_manager, p);
3.1 --- a/src/share/vm/oops/instanceClassLoaderKlass.cpp Mon Dec 09 08:20:45 2013 +0100 3.2 +++ b/src/share/vm/oops/instanceClassLoaderKlass.cpp Tue Dec 10 10:31:00 2013 +0100 3.3 @@ -150,10 +150,6 @@ 3.4 3.5 int InstanceClassLoaderKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) { 3.6 InstanceKlass::oop_update_pointers(cm, obj); 3.7 - ClassLoaderData * const loader_data = java_lang_ClassLoader::loader_data(obj); 3.8 - if (loader_data != NULL) { 3.9 - PSParallelCompact::adjust_class_loader(cm, loader_data); 3.10 - } 3.11 return size_helper(); 3.12 } 3.13 #endif // INCLUDE_ALL_GCS
4.1 --- a/src/share/vm/oops/instanceKlass.cpp Mon Dec 09 08:20:45 2013 +0100 4.2 +++ b/src/share/vm/oops/instanceKlass.cpp Tue Dec 10 10:31:00 2013 +0100 4.3 @@ -2199,7 +2199,6 @@ 4.4 obj, \ 4.5 PSParallelCompact::adjust_pointer(p), \ 4.6 assert_is_in) 4.7 - obj->update_header(cm); 4.8 return size; 4.9 } 4.10
5.1 --- a/src/share/vm/oops/instanceMirrorKlass.cpp Mon Dec 09 08:20:45 2013 +0100 5.2 +++ b/src/share/vm/oops/instanceMirrorKlass.cpp Tue Dec 10 10:31:00 2013 +0100 5.3 @@ -155,8 +155,13 @@ 5.4 // Follow the klass field in the mirror. 5.5 Klass* klass = java_lang_Class::as_Klass(obj); 5.6 if (klass != NULL) { 5.7 - // For anonymous classes we need to handle the class loader data, 5.8 - // otherwise it won't be claimed and can be unloaded. 5.9 + // An anonymous class doesn't have its own class loader, so the call 5.10 + // to follow_klass will mark and push its java mirror instead of the 5.11 + // class loader. When handling the java mirror for an anonymous class 5.12 + // we need to make sure its class loader data is claimed, this is done 5.13 + // by calling follow_class_loader explicitly. For non-anonymous classes 5.14 + // the call to follow_class_loader is made when the class loader itself 5.15 + // is handled. 5.16 if (klass->oop_is_instance() && InstanceKlass::cast(klass)->is_anonymous()) { 5.17 MarkSweep::follow_class_loader(klass->class_loader_data()); 5.18 } else { 5.19 @@ -183,7 +188,18 @@ 5.20 // Follow the klass field in the mirror. 5.21 Klass* klass = java_lang_Class::as_Klass(obj); 5.22 if (klass != NULL) { 5.23 - PSParallelCompact::follow_klass(cm, klass); 5.24 + // An anonymous class doesn't have its own class loader, so the call 5.25 + // to follow_klass will mark and push its java mirror instead of the 5.26 + // class loader. When handling the java mirror for an anonymous class 5.27 + // we need to make sure its class loader data is claimed, this is done 5.28 + // by calling follow_class_loader explicitly. For non-anonymous classes 5.29 + // the call to follow_class_loader is made when the class loader itself 5.30 + // is handled. 5.31 + if (klass->oop_is_instance() && InstanceKlass::cast(klass)->is_anonymous()) { 5.32 + PSParallelCompact::follow_class_loader(cm, klass->class_loader_data()); 5.33 + } else { 5.34 + PSParallelCompact::follow_klass(cm, klass); 5.35 + } 5.36 } else { 5.37 // If klass is NULL then this a mirror for a primitive type. 5.38 // We don't have to follow them, since they are handled as strong 5.39 @@ -332,17 +348,6 @@ 5.40 int size = oop_size(obj); 5.41 InstanceKlass::oop_update_pointers(cm, obj); 5.42 5.43 - // Follow the klass field in the mirror. 5.44 - Klass* klass = java_lang_Class::as_Klass(obj); 5.45 - if (klass != NULL) { 5.46 - PSParallelCompact::adjust_klass(cm, klass); 5.47 - } else { 5.48 - // If klass is NULL then this a mirror for a primitive type. 5.49 - // We don't have to follow them, since they are handled as strong 5.50 - // roots in Universe::oops_do. 5.51 - assert(java_lang_Class::is_primitive(obj), "Sanity check"); 5.52 - } 5.53 - 5.54 InstanceMirrorKlass_OOP_ITERATE( \ 5.55 start_of_static_fields(obj), java_lang_Class::static_oop_field_count(obj),\ 5.56 PSParallelCompact::adjust_pointer(p), \
6.1 --- a/src/share/vm/oops/objArrayKlass.cpp Mon Dec 09 08:20:45 2013 +0100 6.2 +++ b/src/share/vm/oops/objArrayKlass.cpp Tue Dec 10 10:31:00 2013 +0100 6.3 @@ -587,7 +587,6 @@ 6.4 assert (obj->is_objArray(), "obj must be obj array"); 6.5 objArrayOop a = objArrayOop(obj); 6.6 int size = a->object_size(); 6.7 - a->update_header(cm); 6.8 ObjArrayKlass_OOP_ITERATE(a, p, PSParallelCompact::adjust_pointer(p)) 6.9 return size; 6.10 }
7.1 --- a/src/share/vm/oops/oop.hpp Mon Dec 09 08:20:45 2013 +0100 7.2 +++ b/src/share/vm/oops/oop.hpp Tue Dec 10 10:31:00 2013 +0100 7.3 @@ -328,11 +328,6 @@ 7.4 // return the size of this oop. This is used by the MarkSweep collector. 7.5 int adjust_pointers(); 7.6 7.7 -#if INCLUDE_ALL_GCS 7.8 - // Parallel old 7.9 - void update_header(ParCompactionManager* cm); 7.10 -#endif // INCLUDE_ALL_GCS 7.11 - 7.12 // mark-sweep support 7.13 void follow_body(int begin, int end); 7.14
8.1 --- a/src/share/vm/oops/oop.pcgc.inline.hpp Mon Dec 09 08:20:45 2013 +0100 8.2 +++ b/src/share/vm/oops/oop.pcgc.inline.hpp Tue Dec 10 10:31:00 2013 +0100 8.3 @@ -80,8 +80,4 @@ 8.4 return forwardee(); 8.5 } 8.6 8.7 -inline void oopDesc::update_header(ParCompactionManager* cm) { 8.8 - PSParallelCompact::adjust_klass(cm, klass()); 8.9 -} 8.10 - 8.11 #endif // SHARE_VM_OOPS_OOP_PCGC_INLINE_HPP