[RFC] Adding dtrace probe points for more detailed GC information

Lukas Berk lberk at redhat.com
Mon Jul 9 13:54:43 UTC 2012


Hey list,

I've been working on adding probe points to the garbage collection
system with the goal of increased transparency of the internals.  This
will hopefully allow system administrators to make better decisions with 
which configurations of garbage collection to use.

At this point I've identified collect() functions to probe, and keeping
in mind scavenges as a TODO.  Are there any other key processes within
garbage collection that I should be aware of or take into consideration?
The patch (based off of icedtea7 tip) is attached, and any comments are
appreciated.

Cheers,

Lukas

-------------- next part --------------
iff -Nru openjdk.orig/hotspot/src/share/vm/memory/generation.cpp openjdk/hotspot/src/share/vm/memory/generation.cpp
--- openjdk.orig/hotspot/src/share/vm/memory/generation.cpp	2012-06-15 11:36:43.022837742 -0400
+++ openjdk/hotspot/src/share/vm/memory/generation.cpp	2012-06-15 13:35:39.714838057 -0400
@@ -40,6 +40,11 @@
 #include "runtime/java.hpp"
 #include "utilities/copy.hpp"
 #include "utilities/events.hpp"
+#include "utilities/dtrace.hpp"
+
+#ifndef USDT2
+  HS_DTRACE_PROBE_DECL4(provider, name, bool, bool, size_t, bool);
+#endif /* !USDT2 */
 
 Generation::Generation(ReservedSpace rs, size_t initial_size, int level) :
   _level(level),
@@ -471,6 +476,9 @@
   ReferenceProcessorSpanMutator
     x(ref_processor(), GenCollectedHeap::heap()->reserved_region());
   GenMarkSweep::invoke_at_safepoint(_level, ref_processor(), clear_all_soft_refs);
+#ifndef USDT2
+  HS_DTRACE_PROBE4(hotspot, gc__collection__contig, full, clear_all_soft_refs, size, is_tlab);
+#endif  /* !USDT2 */
   SpecializationStats::print();
 }
 
diff -Nru openjdk.orig/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp openjdk/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp
--- openjdk.orig/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp	2012-06-15 11:36:42.164837741 -0400
+++ openjdk/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp	2012-06-15 13:35:45.224838227 -0400
@@ -55,6 +55,11 @@
 #include "runtime/vmThread.hpp"
 #include "services/memoryService.hpp"
 #include "services/runtimeService.hpp"
+#include "utilities/dtrace.hpp"
+
+#ifndef USDT2
+  HS_DTRACE_PROBE_DECL4(provider, name, bool, bool, size_t, bool);
+#endif /* !USDT2 */
 
 // statics
 CMSCollector* ConcurrentMarkSweepGeneration::_collector = NULL;
@@ -1655,6 +1660,10 @@
                            size_t size,
                            bool   tlab)
 {
+
+#ifndef USDT2
+  HS_DTRACE_PROBE4(hotspot, gc__collection__CMS, full, clear_all_soft_refs, size, tlab);
+#endif /* !USDT2 */
   if (!UseCMSCollectionPassing && _collectorState > Idling) {
     // For debugging purposes skip the collection if the state
     // is not currently idle
diff -Nru openjdk.orig/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp openjdk/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp
--- openjdk.orig/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp	2012-06-15 11:36:41.816837741 -0400
+++ openjdk/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp	2012-06-15 13:35:56.298821181 -0400
@@ -49,6 +49,11 @@
 #include "utilities/copy.hpp"
 #include "utilities/globalDefinitions.hpp"
 #include "utilities/workgroup.hpp"
+#include "utilities/dtrace.hpp"
+
+#ifndef USDT2
+  HS_DTRACE_PROBE_DECL4(provider, name, bool, bool, size_t, bool);
+#endif /* !USDT2 */
 
 #ifdef _MSC_VER
 #pragma warning( push )
@@ -878,6 +883,9 @@
                                bool   clear_all_soft_refs,
                                size_t size,
                                bool   is_tlab) {
+#ifndef USDT2
+  HS_DTRACE_PROBE4(hotspot, gc__collection__parnew, full, clear_all_soft_refs, size, is_tlab);
+#endif  /* !USDT2 */
   assert(full || size > 0, "otherwise we don't want to collect");
   GenCollectedHeap* gch = GenCollectedHeap::heap();
   assert(gch->kind() == CollectedHeap::GenCollectedHeap,
diff -Nru openjdk.orig/hotspot/src/share/vm/memory/defNewGeneration.cpp openjdk/hotspot/src/share/vm/memory/defNewGeneration.cpp
--- openjdk.orig/hotspot/src/share/vm/memory/defNewGeneration.cpp	2012-06-15 11:36:42.970837742 -0400
+++ openjdk/hotspot/src/share/vm/memory/defNewGeneration.cpp	2012-06-15 13:36:05.328838805 -0400
@@ -39,6 +39,11 @@
 #include "runtime/java.hpp"
 #include "utilities/copy.hpp"
 #include "utilities/stack.inline.hpp"
+#include "utilities/dtrace.hpp"
+
+#ifndef USDT2
+  HS_DTRACE_PROBE_DECL4(provider, name, bool, bool, size_t, bool);
+#endif /* !USDT2 */
 #ifdef TARGET_OS_FAMILY_linux
 # include "thread_linux.inline.hpp"
 #endif
@@ -528,6 +533,9 @@
                                bool   clear_all_soft_refs,
                                size_t size,
                                bool   is_tlab) {
+#ifndef USDT2
+  HS_DTRACE_PROBE4(hotspot, gc__collection__defnew, full, clear_all_soft_refs, size, is_tlab);
+#endif  /* !USDT2 */
   assert(full || size > 0, "otherwise we don't want to collect");
   GenCollectedHeap* gch = GenCollectedHeap::heap();
   _next_gen = gch->next_gen(this);
diff -Nru openjdk.orig/hotspot/src/share/vm/memory/tenuredGeneration.cpp openjdk/hotspot/src/share/vm/memory/tenuredGeneration.cpp
--- openjdk.orig/hotspot/src/share/vm/memory/tenuredGeneration.cpp	2012-06-15 11:36:43.016837742 -0400
+++ openjdk/hotspot/src/share/vm/memory/tenuredGeneration.cpp	2012-06-15 13:36:08.848839364 -0400
@@ -33,6 +33,11 @@
 #include "memory/tenuredGeneration.hpp"
 #include "oops/oop.inline.hpp"
 #include "runtime/java.hpp"
+#include "utilities/dtrace.hpp"
+
+#ifndef USDT2
+  HS_DTRACE_PROBE_DECL4(provider, name, bool, bool, size_t, bool);
+#endif /* !USDT2 */
 
 TenuredGeneration::TenuredGeneration(ReservedSpace rs,
                                      size_t initial_byte_size, int level,
@@ -307,6 +312,9 @@
                                 size_t size,
                                 bool   is_tlab) {
   retire_alloc_buffers_before_full_gc();
+#ifndef USDT2
+  HS_DTRACE_PROBE4(hotspot, gc__collection__tenured, full, clear_all_soft_refs, size, is_tlab);
+#endif  /* !USDT2 */
   OneContigSpaceCardGeneration::collect(full, clear_all_soft_refs,
                                         size, is_tlab);
 }
diff -Nru openjdk.orig/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp openjdk/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp
--- openjdk.orig/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp
+++ openjdk/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp
@@ -40,8 +40,13 @@
 #include "runtime/handles.inline.hpp"
 #include "runtime/java.hpp"
 #include "runtime/vmThread.hpp"
+#include "utilities/dtrace.hpp"
 #include "utilities/vmError.hpp"
 
+#ifndef USDT2
+  HS_DTRACE_PROBE_DECL1(provider, name, *uintptr_t);
+#endif /* !USDT2 */
+
 PSYoungGen*  ParallelScavengeHeap::_young_gen = NULL;
 PSOldGen*    ParallelScavengeHeap::_old_gen = NULL;
 PSPermGen*   ParallelScavengeHeap::_perm_gen = NULL;
@@ -806,6 +811,9 @@
   }
 
   VM_ParallelGCSystemGC op(gc_count, full_gc_count, cause);
+#ifndef USDT2
+  HS_DTRACE_PROBE1(hotspot, gc__collection__parscavenge, op);
+#endif /* !USDT2 */
   VMThread::execute(&op);
 }

diff -Nru openjdk.orig/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp openjdk/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp 
--- openjdk.orig/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp
+++ openjdk/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp
@@ -53,11 +53,16 @@
 #include "runtime/vmThread.hpp"
 #include "services/management.hpp"
 #include "services/memoryService.hpp"
+#include "utilities/dtrace.hpp"
 #include "utilities/events.hpp"
 #include "utilities/stack.inline.hpp"
 
 #include <math.h>
 
+#ifndef USDT2
+  HS_DTRACE_PROBE_DECL1(provider, name, *uintptr_t);
+#endif /* !USDT2 */
+
 // All sizes are in HeapWords.
 const size_t ParallelCompactData::Log2RegionSize  = 9; // 512 words
 const size_t ParallelCompactData::RegionSize      = (size_t)1 << Log2RegionSize;
@@ -1967,8 +1972,10 @@
   assert(SafepointSynchronize::is_at_safepoint(), "should be at safepoint");
   assert(Thread::current() == (Thread*)VMThread::vm_thread(),
          "should be in vm thread");
-
   ParallelScavengeHeap* heap = gc_heap();
+#ifndef USDT2
+  HS_DTRACE_PROBE1(hotspot, gc__collection__par, heap);
+#endif /* !USDT2 */
   GCCause::Cause gc_cause = heap->gc_cause();
   assert(!heap->is_gc_active(), "not reentrant");
 
--- openjdk.orig/hotspot/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp	2012-06-26 09:24:22.472325287 -0400
+++ openjdk/hotspot/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp	2012-07-05 10:43:08.273800575 -0400
@@ -45,8 +45,13 @@
 #include "runtime/thread.hpp"
 #include "runtime/vmThread.hpp"
 #include "utilities/copy.hpp"
+#include "utilities/dtrace.hpp"
 #include "utilities/events.hpp"
 
+#ifndef USDT2
+  HS_DTRACE_PROBE_DECL1(provider, name, *uintptr_t);
+#endif /* !USDT2 */
+
 class HeapRegion;
 
 void G1MarkSweep::invoke_at_safepoint(ReferenceProcessor* rp,
@@ -83,7 +88,9 @@
   // We should save the marks of the currently locked biased monitors.
   // The marking doesn't preserve the marks of biased objects.
   BiasedLocking::preserve_marks();
-
+#ifndef USDT2
+  HS_DTRACE_PROBE1(hotspot, gc__collection__G1, sh);
+#endif /* !USDT2 */
   mark_sweep_phase1(marked_for_unloading, clear_all_softrefs);
 
   mark_sweep_phase2();
--- openjdk.orig/hotspot/src/share/vm/compiler/oopMap.cpp	2012-06-26 09:24:22.390325184 -0400
+++ openjdk/hotspot/src/share/vm/compiler/oopMap.cpp	2012-07-06 10:12:44.981413003 -0400
@@ -33,9 +33,13 @@
 #include "memory/resourceArea.hpp"
 #include "runtime/frame.inline.hpp"
 #include "runtime/signature.hpp"
+#include "utilities/dtrace.hpp"
 #ifdef COMPILER1
 #include "c1/c1_Defs.hpp"
 #endif
+#ifndef USDT2
+  HS_DTRACE_PROBE_DECL1(provider, name, *uintptr_t);
+#endif /* !USDT2 */
 
 // OopMapStream
 
@@ -677,6 +681,9 @@
                     " - Derived: " INTPTR_FORMAT "  Base: " INTPTR_FORMAT " (Offset: %d)",
           derived_loc, (address)*derived_loc, (address)base, offset);
     }
+#ifndef USDT2
+  HS_DTRACE_PROBE1(hotspot, gc__collection__delete, entry);
+#endif /* !USDT2 */
 
     // Delete entry
     delete entry;
--- openjdk.orig/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.hpp	2012-06-26 09:24:22.504325327 -0400
+++ openjdk/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.hpp	2012-07-06 12:22:15.316157947 -0400
@@ -33,6 +33,11 @@
 #include "gc_implementation/shared/mutableSpace.hpp"
 #include "memory/sharedHeap.hpp"
 #include "oops/oop.hpp"
+#include "utilities/dtrace.hpp"
+
+#ifndef USDT2
+  HS_DTRACE_PROBE_DECL2(provider, name, *uintptr_t, *uintptr_t);
+#endif /* !USDT2 */
 
 class ParallelScavengeHeap;
 class PSAdaptiveSizePolicy;
@@ -1270,6 +1275,9 @@
   if (!oopDesc::is_null(heap_oop)) {
     oop obj     = oopDesc::decode_heap_oop_not_null(heap_oop);
     oop new_obj = (oop)summary_data().calc_new_pointer(obj);
+#ifndef USDT2
+  HS_DTRACE_PROBE2(hotspot, gc__collection__move, obj, new_obj);
+#endif /* !USDT2 */
     assert(new_obj != NULL ||                     // is forwarding ptr?
            obj->is_shared(),                      // never forwarded?
            "should be forwarded");


More information about the hotspot-gc-dev mailing list