src/share/vm/memory/metaspace.cpp

changeset 6417
daef39043d2c
parent 6337
ab36007d6358
child 6418
bc7714614ad8
     1.1 --- a/src/share/vm/memory/metaspace.cpp	Fri Mar 21 10:16:35 2014 +0100
     1.2 +++ b/src/share/vm/memory/metaspace.cpp	Fri Mar 21 10:17:47 2014 +0100
     1.3 @@ -32,7 +32,9 @@
     1.4  #include "memory/gcLocker.hpp"
     1.5  #include "memory/metachunk.hpp"
     1.6  #include "memory/metaspace.hpp"
     1.7 +#include "memory/metaspaceGCThresholdUpdater.hpp"
     1.8  #include "memory/metaspaceShared.hpp"
     1.9 +#include "memory/metaspaceTracer.hpp"
    1.10  #include "memory/resourceArea.hpp"
    1.11  #include "memory/universe.hpp"
    1.12  #include "runtime/atomic.inline.hpp"
    1.13 @@ -57,6 +59,7 @@
    1.14  MetaWord* last_allocated = 0;
    1.15  
    1.16  size_t Metaspace::_compressed_class_space_size;
    1.17 +const MetaspaceTracer* Metaspace::_tracer = NULL;
    1.18  
    1.19  // Used in declarations in SpaceManager and ChunkManager
    1.20  enum ChunkIndex {
    1.21 @@ -1436,19 +1439,21 @@
    1.22      expand_bytes = align_size_up(expand_bytes, Metaspace::commit_alignment());
    1.23      // Don't expand unless it's significant
    1.24      if (expand_bytes >= MinMetaspaceExpansion) {
    1.25 -      MetaspaceGC::inc_capacity_until_GC(expand_bytes);
    1.26 -    }
    1.27 -    if (PrintGCDetails && Verbose) {
    1.28 -      size_t new_capacity_until_GC = capacity_until_GC;
    1.29 -      gclog_or_tty->print_cr("    expanding:"
    1.30 -                    "  minimum_desired_capacity: %6.1fKB"
    1.31 -                    "  expand_bytes: %6.1fKB"
    1.32 -                    "  MinMetaspaceExpansion: %6.1fKB"
    1.33 -                    "  new metaspace HWM:  %6.1fKB",
    1.34 -                    minimum_desired_capacity / (double) K,
    1.35 -                    expand_bytes / (double) K,
    1.36 -                    MinMetaspaceExpansion / (double) K,
    1.37 -                    new_capacity_until_GC / (double) K);
    1.38 +      size_t new_capacity_until_GC = MetaspaceGC::inc_capacity_until_GC(expand_bytes);
    1.39 +      Metaspace::tracer()->report_gc_threshold(capacity_until_GC,
    1.40 +                                               new_capacity_until_GC,
    1.41 +                                               MetaspaceGCThresholdUpdater::ComputeNewSize);
    1.42 +      if (PrintGCDetails && Verbose) {
    1.43 +        gclog_or_tty->print_cr("    expanding:"
    1.44 +                      "  minimum_desired_capacity: %6.1fKB"
    1.45 +                      "  expand_bytes: %6.1fKB"
    1.46 +                      "  MinMetaspaceExpansion: %6.1fKB"
    1.47 +                      "  new metaspace HWM:  %6.1fKB",
    1.48 +                      minimum_desired_capacity / (double) K,
    1.49 +                      expand_bytes / (double) K,
    1.50 +                      MinMetaspaceExpansion / (double) K,
    1.51 +                      new_capacity_until_GC / (double) K);
    1.52 +      }
    1.53      }
    1.54      return;
    1.55    }
    1.56 @@ -1527,7 +1532,10 @@
    1.57    // Don't shrink unless it's significant
    1.58    if (shrink_bytes >= MinMetaspaceExpansion &&
    1.59        ((capacity_until_GC - shrink_bytes) >= MetaspaceSize)) {
    1.60 -    MetaspaceGC::dec_capacity_until_GC(shrink_bytes);
    1.61 +    size_t new_capacity_until_GC = MetaspaceGC::dec_capacity_until_GC(shrink_bytes);
    1.62 +    Metaspace::tracer()->report_gc_threshold(capacity_until_GC,
    1.63 +                                             new_capacity_until_GC,
    1.64 +                                             MetaspaceGCThresholdUpdater::ComputeNewSize);
    1.65    }
    1.66  }
    1.67  
    1.68 @@ -3131,6 +3139,7 @@
    1.69    }
    1.70  
    1.71    MetaspaceGC::initialize();
    1.72 +  _tracer = new MetaspaceTracer();
    1.73  }
    1.74  
    1.75  Metachunk* Metaspace::get_initialization_chunk(MetadataType mdtype,
    1.76 @@ -3219,8 +3228,12 @@
    1.77    assert(delta_bytes > 0, "Must be");
    1.78  
    1.79    size_t after_inc = MetaspaceGC::inc_capacity_until_GC(delta_bytes);
    1.80 +
    1.81 +  // capacity_until_GC might be updated concurrently, must calculate previous value.
    1.82    size_t before_inc = after_inc - delta_bytes;
    1.83  
    1.84 +  tracer()->report_gc_threshold(before_inc, after_inc,
    1.85 +                                MetaspaceGCThresholdUpdater::ExpandAndAllocate);
    1.86    if (PrintGCDetails && Verbose) {
    1.87      gclog_or_tty->print_cr("Increase capacity to GC from " SIZE_FORMAT
    1.88          " to " SIZE_FORMAT, before_inc, after_inc);

mercurial