< prev index next >

src/hotspot/share/gc/shenandoah/heuristics/shenandoahAdaptiveHeuristics.hpp

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.

*** 23,12 ***
--- 24,14 ---
   */
  
  #ifndef SHARE_GC_SHENANDOAH_HEURISTICS_SHENANDOAHADAPTIVEHEURISTICS_HPP
  #define SHARE_GC_SHENANDOAH_HEURISTICS_SHENANDOAHADAPTIVEHEURISTICS_HPP
  
+ #include "memory/allocation.hpp"
  #include "gc/shenandoah/heuristics/shenandoahHeuristics.hpp"
  #include "gc/shenandoah/shenandoahPhaseTimings.hpp"
+ #include "gc/shenandoah/shenandoahSharedVariables.hpp"
  #include "utilities/numberSeq.hpp"
  
  class ShenandoahAllocationRate : public CHeapObj<mtGC> {
   public:
    explicit ShenandoahAllocationRate();

*** 36,11 ***
  
    double sample(size_t allocated);
  
    double upper_bound(double sds) const;
    bool is_spiking(double rate, double threshold) const;
- 
   private:
  
    double instantaneous_rate(double time, size_t allocated) const;
  
    double _last_sample_time;
--- 39,10 ---

*** 48,13 ***
    double _interval_sec;
    TruncatedSeq _rate;
    TruncatedSeq _rate_avg;
  };
  
  class ShenandoahAdaptiveHeuristics : public ShenandoahHeuristics {
  public:
!   ShenandoahAdaptiveHeuristics();
  
    virtual ~ShenandoahAdaptiveHeuristics();
  
    virtual void choose_collection_set_from_regiondata(ShenandoahCollectionSet* cset,
                                                       RegionData* data, size_t size,
--- 50,24 ---
    double _interval_sec;
    TruncatedSeq _rate;
    TruncatedSeq _rate_avg;
  };
  
+ /*
+  * The adaptive heuristic tracks the allocation behavior and average cycle
+  * time of the application. It attempts to start a cycle with enough time
+  * to complete before the available memory is exhausted. It errors on the
+  * side of starting cycles early to avoid allocation failures (degenerated
+  * cycles).
+  *
+  * This heuristic limits the number of regions for evacuation such that the
+  * evacuation reserve is respected. This helps it avoid allocation failures
+  * during evacuation. It preferentially selects regions with the most garbage.
+  */
  class ShenandoahAdaptiveHeuristics : public ShenandoahHeuristics {
  public:
!   ShenandoahAdaptiveHeuristics(ShenandoahSpaceInfo* space_info);
  
    virtual ~ShenandoahAdaptiveHeuristics();
  
    virtual void choose_collection_set_from_regiondata(ShenandoahCollectionSet* cset,
                                                       RegionData* data, size_t size,

*** 96,15 ***
  
    void adjust_last_trigger_parameters(double amount);
    void adjust_margin_of_error(double amount);
    void adjust_spike_threshold(double amount);
  
    ShenandoahAllocationRate _allocation_rate;
  
    // The margin of error expressed in standard deviations to add to our
    // average cycle time and allocation rate. As this value increases we
!   // tend to over estimate the rate at which mutators will deplete the
    // heap. In other words, erring on the side of caution will trigger more
    // concurrent GCs.
    double _margin_of_error_sd;
  
    // The allocation spike threshold is expressed in standard deviations.
--- 109,16 ---
  
    void adjust_last_trigger_parameters(double amount);
    void adjust_margin_of_error(double amount);
    void adjust_spike_threshold(double amount);
  
+ protected:
    ShenandoahAllocationRate _allocation_rate;
  
    // The margin of error expressed in standard deviations to add to our
    // average cycle time and allocation rate. As this value increases we
!   // tend to overestimate the rate at which mutators will deplete the
    // heap. In other words, erring on the side of caution will trigger more
    // concurrent GCs.
    double _margin_of_error_sd;
  
    // The allocation spike threshold is expressed in standard deviations.

*** 123,8 ***
--- 137,14 ---
  
    // Keep track of the available memory at the end of a GC cycle. This
    // establishes what is 'normal' for the application and is used as a
    // source of feedback to adjust trigger parameters.
    TruncatedSeq _available;
+ 
+   // A conservative minimum threshold of free space that we'll try to maintain when possible.
+   // For example, we might trigger a concurrent gc if we are likely to drop below
+   // this threshold, or we might consider this when dynamically resizing generations
+   // in the generational case. Controlled by global flag ShenandoahMinFreeThreshold.
+   size_t min_free_threshold();
  };
  
  #endif // SHARE_GC_SHENANDOAH_HEURISTICS_SHENANDOAHADAPTIVEHEURISTICS_HPP
< prev index next >