< prev index next >

## src/hotspot/share/gc/shenandoah/heuristics/shenandoahHeuristics.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.
```

```@@ -24,15 +25,14 @@

#ifndef SHARE_GC_SHENANDOAH_HEURISTICS_SHENANDOAHHEURISTICS_HPP
#define SHARE_GC_SHENANDOAH_HEURISTICS_SHENANDOAHHEURISTICS_HPP

#include "gc/shenandoah/heuristics/shenandoahSpaceInfo.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"
+ #include "utilities/numberSeq.hpp"

#define SHENANDOAH_ERGO_DISABLE_FLAG(name)                                  \
do {                                                                      \
if (FLAG_IS_DEFAULT(name) && (name)) {                                  \
log_info(gc)("Heuristics ergonomically sets -XX:-" #name);            \
```

```@@ -68,32 +68,55 @@
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;
+     union {
+       size_t _garbage;          // Not used by old-gen heuristics.
+       size_t _live_data;        // Only used for old-gen heuristics, which prioritizes retention of _live_data over garbage reclaim
+     } _u;
} RegionData;

// Source of information about the memory space managed by this heuristic
ShenandoahSpaceInfo* _space_info;

+   // Depending on generation mode, region data represents the results of the relevant
+   // most recently completed marking pass:
+   //   - in GLOBAL mode, global marking pass
+   //   - in OLD mode,    old-gen marking pass
+   //   - in YOUNG mode,  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;

+   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);
```

```@@ -104,19 +127,23 @@

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;
+   }
+
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();

```

```@@ -125,16 +152,19 @@
virtual void record_requested_gc();

virtual void choose_collection_set(ShenandoahCollectionSet* collection_set);

virtual bool can_unload_classes();
+
+   // This indicates whether or not the current cycle should unload classes.
+   // It does NOT indicate that a cycle should be started.
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 >