< prev index next > src/hotspot/share/gc/shenandoah/heuristics/shenandoahHeuristics.hpp
Print this page
*/
#ifndef SHARE_GC_SHENANDOAH_HEURISTICS_SHENANDOAHHEURISTICS_HPP
#define SHARE_GC_SHENANDOAH_HEURISTICS_SHENANDOAHHEURISTICS_HPP
- #include "gc/shenandoah/shenandoahHeap.hpp"
#include "gc/shenandoah/shenandoahPhaseTimings.hpp"
#include "gc/shenandoah/shenandoahSharedVariables.hpp"
#include "memory/allocation.hpp"
#include "runtime/globals_extension.hpp"
} \
} while (0)
class ShenandoahCollectionSet;
class ShenandoahHeapRegion;
+ class ShenandoahGeneration;
+ class ShenandoahOldHeuristics;
class ShenandoahHeuristics : public CHeapObj<mtGC> {
static const intx Concurrent_Adjust = -1; // recover from penalties
static const intx Degenerated_Penalty = 10; // how much to penalize average GC duration history on Degenerated GC
static const intx Full_Penalty = 20; // how much to penalize average GC duration history on Full GC
protected:
+ static const uint Moving_Average_Samples = 10; // Number of samples to store in moving averages
+
typedef struct {
ShenandoahHeapRegion* _region;
size_t _garbage;
} RegionData;
+ ShenandoahGeneration* _generation;
+
+ // if (_generation->generation_mode() == GLOBAL) _region_data represents
+ // the results of most recently completed global marking pass
+ // if (_generation->generation_mode() == OLD) _region_data represents
+ // the results of most recently completed old-gen marking pass
+ // if (_generation->generation_mode() == YOUNG) _region_data represents
+ // the results of most recently completed young-gen marking pass
+ //
+ // Note that there is some redundancy represented in _region_data because
+ // each instance is an array large enough to hold all regions. However,
+ // any region in young-gen is not in old-gen. And any time we are
+ // making use of the GLOBAL data, there is no need to maintain the
+ // YOUNG or OLD data. Consider this redundancy of data structure to
+ // have negligible cost unless proven otherwise.
RegionData* _region_data;
uint _degenerated_cycles_in_a_row;
uint _successful_cycles_in_a_row;
+ size_t _guaranteed_gc_interval;
+
double _cycle_start;
double _last_cycle_end;
size_t _gc_times_learned;
intx _gc_time_penalties;
- TruncatedSeq* _gc_time_history;
+ TruncatedSeq* _gc_cycle_time_history;
// There may be many threads that contend to set this flag
ShenandoahSharedFlag _metaspace_oom;
static int compare_by_garbage(RegionData a, RegionData b);
+ // TODO: We need to enhance this API to give visibility to accompanying old-gen evacuation effort.
+ // In the case that the old-gen evacuation effort is small or zero, the young-gen heuristics
+ // should feel free to dedicate increased efforts to young-gen evacuation.
+
virtual void choose_collection_set_from_regiondata(ShenandoahCollectionSet* set,
RegionData* data, size_t data_size,
size_t free) = 0;
void adjust_penalty(intx step);
+ bool in_generation(ShenandoahHeapRegion* region);
+
+ size_t min_free_threshold();
+
public:
- ShenandoahHeuristics();
+ ShenandoahHeuristics(ShenandoahGeneration* generation);
virtual ~ShenandoahHeuristics();
void record_metaspace_oom() { _metaspace_oom.set(); }
void clear_metaspace_oom() { _metaspace_oom.unset(); }
bool has_metaspace_oom() const { return _metaspace_oom.is_set(); }
+ void set_guaranteed_gc_interval(size_t guaranteed_gc_interval) {
+ _guaranteed_gc_interval = guaranteed_gc_interval;
+ }
+
+ uint degenerated_cycles_in_a_row() {
+ return _degenerated_cycles_in_a_row;
+ }
+
virtual void record_cycle_start();
virtual void record_cycle_end();
virtual bool should_start_gc();
virtual bool should_degenerate_cycle();
- virtual void record_success_concurrent();
+ virtual void record_success_concurrent(bool abbreviated);
virtual void record_success_degenerated();
virtual void record_success_full();
virtual void record_allocation_failure_gc();
virtual void record_requested_gc();
- virtual void choose_collection_set(ShenandoahCollectionSet* collection_set);
+ virtual void reset_gc_learning();
+
+ virtual size_t select_aged_regions(size_t old_available, size_t num_regions, bool preselected_regions[]);
+
+ virtual void choose_collection_set(ShenandoahCollectionSet* collection_set, ShenandoahOldHeuristics* old_heuristics);
virtual bool can_unload_classes();
virtual bool can_unload_classes_normal();
virtual bool should_unload_classes();
virtual const char* name() = 0;
virtual bool is_diagnostic() = 0;
virtual bool is_experimental() = 0;
virtual void initialize();
- double time_since_last_gc() const;
+ double elapsed_cycle_time() const;
};
#endif // SHARE_GC_SHENANDOAH_HEURISTICS_SHENANDOAHHEURISTICS_HPP
< prev index next >