< prev index next >

src/hotspot/share/gc/shenandoah/heuristics/shenandoahCompactHeuristics.cpp

Print this page
*** 1,7 ***
--- 1,8 ---
  /*
   * Copyright (c) 2018, 2019, Red Hat, Inc. All rights reserved.
+  * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.

*** 30,11 ***
  #include "gc/shenandoah/shenandoahHeap.inline.hpp"
  #include "gc/shenandoah/shenandoahHeapRegion.inline.hpp"
  #include "logging/log.hpp"
  #include "logging/logTag.hpp"
  
! ShenandoahCompactHeuristics::ShenandoahCompactHeuristics() : ShenandoahHeuristics() {
    SHENANDOAH_ERGO_ENABLE_FLAG(ExplicitGCInvokesConcurrent);
    SHENANDOAH_ERGO_ENABLE_FLAG(ShenandoahImplicitGCInvokesConcurrent);
    SHENANDOAH_ERGO_ENABLE_FLAG(ShenandoahUncommit);
    SHENANDOAH_ERGO_ENABLE_FLAG(ShenandoahAlwaysClearSoftRefs);
    SHENANDOAH_ERGO_OVERRIDE_DEFAULT(ShenandoahAllocationThreshold,  10);
--- 31,12 ---
  #include "gc/shenandoah/shenandoahHeap.inline.hpp"
  #include "gc/shenandoah/shenandoahHeapRegion.inline.hpp"
  #include "logging/log.hpp"
  #include "logging/logTag.hpp"
  
! ShenandoahCompactHeuristics::ShenandoahCompactHeuristics(ShenandoahSpaceInfo* space_info) :
+   ShenandoahHeuristics(space_info) {
    SHENANDOAH_ERGO_ENABLE_FLAG(ExplicitGCInvokesConcurrent);
    SHENANDOAH_ERGO_ENABLE_FLAG(ShenandoahImplicitGCInvokesConcurrent);
    SHENANDOAH_ERGO_ENABLE_FLAG(ShenandoahUncommit);
    SHENANDOAH_ERGO_ENABLE_FLAG(ShenandoahAlwaysClearSoftRefs);
    SHENANDOAH_ERGO_OVERRIDE_DEFAULT(ShenandoahAllocationThreshold,  10);

*** 43,15 ***
    SHENANDOAH_ERGO_OVERRIDE_DEFAULT(ShenandoahGuaranteedGCInterval, 30000);
    SHENANDOAH_ERGO_OVERRIDE_DEFAULT(ShenandoahGarbageThreshold,     10);
  }
  
  bool ShenandoahCompactHeuristics::should_start_gc() {
!   ShenandoahHeap* heap = ShenandoahHeap::heap();
! 
!   size_t max_capacity = heap->max_capacity();
-   size_t capacity = heap->soft_max_capacity();
-   size_t available = heap->free_set()->available();
  
    // Make sure the code below treats available without the soft tail.
    size_t soft_tail = max_capacity - capacity;
    available = (available > soft_tail) ? (available - soft_tail) : 0;
  
--- 45,13 ---
    SHENANDOAH_ERGO_OVERRIDE_DEFAULT(ShenandoahGuaranteedGCInterval, 30000);
    SHENANDOAH_ERGO_OVERRIDE_DEFAULT(ShenandoahGarbageThreshold,     10);
  }
  
  bool ShenandoahCompactHeuristics::should_start_gc() {
!   size_t max_capacity = _space_info->max_capacity();
!   size_t capacity = _space_info->soft_max_capacity();
!   size_t available = _space_info->available();
  
    // Make sure the code below treats available without the soft tail.
    size_t soft_tail = max_capacity - capacity;
    available = (available > soft_tail) ? (available - soft_tail) : 0;
  

*** 63,11 ***
                   byte_size_in_proper_unit(available),     proper_unit_for_byte_size(available),
                   byte_size_in_proper_unit(min_threshold), proper_unit_for_byte_size(min_threshold));
      return true;
    }
  
!   size_t bytes_allocated = heap->bytes_allocated_since_gc_start();
    if (bytes_allocated > threshold_bytes_allocated) {
      log_info(gc)("Trigger: Allocated since last cycle (" SIZE_FORMAT "%s) is larger than allocation threshold (" SIZE_FORMAT "%s)",
                   byte_size_in_proper_unit(bytes_allocated),           proper_unit_for_byte_size(bytes_allocated),
                   byte_size_in_proper_unit(threshold_bytes_allocated), proper_unit_for_byte_size(threshold_bytes_allocated));
      return true;
--- 63,11 ---
                   byte_size_in_proper_unit(available),     proper_unit_for_byte_size(available),
                   byte_size_in_proper_unit(min_threshold), proper_unit_for_byte_size(min_threshold));
      return true;
    }
  
!   size_t bytes_allocated = _space_info->bytes_allocated_since_gc_start();
    if (bytes_allocated > threshold_bytes_allocated) {
      log_info(gc)("Trigger: Allocated since last cycle (" SIZE_FORMAT "%s) is larger than allocation threshold (" SIZE_FORMAT "%s)",
                   byte_size_in_proper_unit(bytes_allocated),           proper_unit_for_byte_size(bytes_allocated),
                   byte_size_in_proper_unit(threshold_bytes_allocated), proper_unit_for_byte_size(threshold_bytes_allocated));
      return true;
< prev index next >