8065331: Add trace events for failed allocations

Mon, 02 Mar 2015 14:50:53 +0100

author
mlarsson
date
Mon, 02 Mar 2015 14:50:53 +0100
changeset 7688
a4ad5d51d29c
parent 7687
af8f16ac392c
child 7689
cff166f839f6

8065331: Add trace events for failed allocations
Reviewed-by: ehelin, jwilhelm

src/share/vm/gc_implementation/shared/vmGCOperations.cpp file | annotate | diff | comparison | revisions
src/share/vm/gc_implementation/shared/vmGCOperations.hpp file | annotate | diff | comparison | revisions
src/share/vm/gc_interface/allocTracer.cpp file | annotate | diff | comparison | revisions
src/share/vm/gc_interface/allocTracer.hpp file | annotate | diff | comparison | revisions
src/share/vm/trace/trace.xml file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/gc_implementation/shared/vmGCOperations.cpp	Thu Apr 09 15:59:26 2015 +0200
     1.2 +++ b/src/share/vm/gc_implementation/shared/vmGCOperations.cpp	Mon Mar 02 14:50:53 2015 +0100
     1.3 @@ -209,6 +209,18 @@
     1.4    gch->do_full_collection(gch->must_clear_all_soft_refs(), _max_level);
     1.5  }
     1.6  
     1.7 +VM_CollectForMetadataAllocation::VM_CollectForMetadataAllocation(ClassLoaderData* loader_data,
     1.8 +                                                                 size_t size,
     1.9 +                                                                 Metaspace::MetadataType mdtype,
    1.10 +                                                                 uint gc_count_before,
    1.11 +                                                                 uint full_gc_count_before,
    1.12 +                                                                 GCCause::Cause gc_cause)
    1.13 +    : VM_GC_Operation(gc_count_before, gc_cause, full_gc_count_before, true),
    1.14 +      _loader_data(loader_data), _size(size), _mdtype(mdtype), _result(NULL) {
    1.15 +  assert(_size != 0, "An allocation should always be requested with this operation.");
    1.16 +  AllocTracer::send_allocation_requiring_gc_event(_size * HeapWordSize, GCId::peek());
    1.17 +}
    1.18 +
    1.19  // Returns true iff concurrent GCs unloads metadata.
    1.20  bool VM_CollectForMetadataAllocation::initiate_concurrent_GC() {
    1.21  #if INCLUDE_ALL_GCS
    1.22 @@ -313,3 +325,11 @@
    1.23      set_gc_locked();
    1.24    }
    1.25  }
    1.26 +
    1.27 +VM_CollectForAllocation::VM_CollectForAllocation(size_t word_size, uint gc_count_before, GCCause::Cause cause)
    1.28 +    : VM_GC_Operation(gc_count_before, cause), _result(NULL), _word_size(word_size) {
    1.29 +  // Only report if operation was really caused by an allocation.
    1.30 +  if (_word_size != 0) {
    1.31 +    AllocTracer::send_allocation_requiring_gc_event(_word_size * HeapWordSize, GCId::peek());
    1.32 +  }
    1.33 +}
     2.1 --- a/src/share/vm/gc_implementation/shared/vmGCOperations.hpp	Thu Apr 09 15:59:26 2015 +0200
     2.2 +++ b/src/share/vm/gc_implementation/shared/vmGCOperations.hpp	Mon Mar 02 14:50:53 2015 +0100
     2.3 @@ -25,6 +25,7 @@
     2.4  #ifndef SHARE_VM_GC_IMPLEMENTATION_SHARED_VMGCOPERATIONS_HPP
     2.5  #define SHARE_VM_GC_IMPLEMENTATION_SHARED_VMGCOPERATIONS_HPP
     2.6  
     2.7 +#include "gc_implementation/shared/gcId.hpp"
     2.8  #include "memory/heapInspection.hpp"
     2.9  #include "runtime/handles.hpp"
    2.10  #include "runtime/jniHandles.hpp"
    2.11 @@ -168,8 +169,7 @@
    2.12    HeapWord* _result;    // Allocation result (NULL if allocation failed)
    2.13  
    2.14   public:
    2.15 -  VM_CollectForAllocation(size_t word_size, uint gc_count_before, GCCause::Cause cause)
    2.16 -    : VM_GC_Operation(gc_count_before, cause), _result(NULL), _word_size(word_size) {}
    2.17 +  VM_CollectForAllocation(size_t word_size, uint gc_count_before, GCCause::Cause cause);
    2.18  
    2.19    HeapWord* result() const {
    2.20      return _result;
    2.21 @@ -220,10 +220,7 @@
    2.22                                    size_t size, Metaspace::MetadataType mdtype,
    2.23                                    uint gc_count_before,
    2.24                                    uint full_gc_count_before,
    2.25 -                                  GCCause::Cause gc_cause)
    2.26 -    : VM_GC_Operation(gc_count_before, gc_cause, full_gc_count_before, true),
    2.27 -      _loader_data(loader_data), _size(size), _mdtype(mdtype), _result(NULL) {
    2.28 -  }
    2.29 +                                  GCCause::Cause gc_cause);
    2.30    virtual VMOp_Type type() const { return VMOp_CollectForMetadataAllocation; }
    2.31    virtual void doit();
    2.32    MetaWord* result() const       { return _result; }
     3.1 --- a/src/share/vm/gc_interface/allocTracer.cpp	Thu Apr 09 15:59:26 2015 +0200
     3.2 +++ b/src/share/vm/gc_interface/allocTracer.cpp	Mon Mar 02 14:50:53 2015 +0100
     3.3 @@ -1,5 +1,5 @@
     3.4  /*
     3.5 - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
     3.6 + * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
     3.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3.8   *
     3.9   * This code is free software; you can redistribute it and/or modify it
    3.10 @@ -23,6 +23,7 @@
    3.11   */
    3.12  
    3.13  #include "precompiled.hpp"
    3.14 +#include "gc_implementation/shared/gcId.hpp"
    3.15  #include "gc_interface/allocTracer.hpp"
    3.16  #include "trace/tracing.hpp"
    3.17  #include "runtime/handles.hpp"
    3.18 @@ -46,3 +47,12 @@
    3.19      event.commit();
    3.20    }
    3.21  }
    3.22 +
    3.23 +void AllocTracer::send_allocation_requiring_gc_event(size_t size, const GCId& gcId) {
    3.24 +  EventAllocationRequiringGC event;
    3.25 +  if (event.should_commit()) {
    3.26 +    event.set_gcId(gcId.id());
    3.27 +    event.set_size(size);
    3.28 +    event.commit();
    3.29 +  }
    3.30 +}
     4.1 --- a/src/share/vm/gc_interface/allocTracer.hpp	Thu Apr 09 15:59:26 2015 +0200
     4.2 +++ b/src/share/vm/gc_interface/allocTracer.hpp	Mon Mar 02 14:50:53 2015 +0100
     4.3 @@ -1,5 +1,5 @@
     4.4  /*
     4.5 - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
     4.6 + * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
     4.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4.8   *
     4.9   * This code is free software; you can redistribute it and/or modify it
    4.10 @@ -32,6 +32,7 @@
    4.11    public:
    4.12      static void send_allocation_outside_tlab_event(KlassHandle klass, size_t alloc_size);
    4.13      static void send_allocation_in_new_tlab_event(KlassHandle klass, size_t tlab_size, size_t alloc_size);
    4.14 +    static void send_allocation_requiring_gc_event(size_t size, const GCId& gcId);
    4.15  };
    4.16  
    4.17  #endif /* SHARE_VM_GC_INTERFACE_ALLOCTRACER_HPP */
     5.1 --- a/src/share/vm/trace/trace.xml	Thu Apr 09 15:59:26 2015 +0200
     5.2 +++ b/src/share/vm/trace/trace.xml	Mon Mar 02 14:50:53 2015 +0100
     5.3 @@ -1,6 +1,6 @@
     5.4  <?xml version="1.0" encoding="utf-8"?>
     5.5  <!--
     5.6 - Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
     5.7 + Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
     5.8   DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5.9  
    5.10   This code is free software; you can redistribute it and/or modify it
    5.11 @@ -352,6 +352,12 @@
    5.12        <value type="UTF8" field="name" label="Name" />
    5.13      </event>
    5.14  
    5.15 +    <event id="AllocationRequiringGC" path="vm/gc/detailed/allocation_requiring_gc" label="Allocation Requiring GC"
    5.16 +           has_thread="true" has_stacktrace="true"  is_instant="true">
    5.17 +      <value type="UINT" field="gcId"  label="Pending GC ID" relation="GC_ID" />
    5.18 +      <value type="BYTES64" field="size" label="Allocation Size" />
    5.19 +    </event>
    5.20 +
    5.21      <!-- Compiler events -->
    5.22  
    5.23      <event id="Compilation" path="vm/compiler/compilation" label="Compilation"

mercurial