Skip to content

Commit

Permalink
8320877: Shenandoah: Remove ShenandoahUnloadClassesFrequency support
Browse files Browse the repository at this point in the history
Backport-of: b65ccff357e2e294b027f693ceb3d25410236a6b
  • Loading branch information
shipilev committed Jan 16, 2024
1 parent 7fe7cfc commit b114a5e
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ ShenandoahAggressiveHeuristics::ShenandoahAggressiveHeuristics() : ShenandoahHeu

// Aggressive evacuates everything, so it needs as much evac space as it can get
SHENANDOAH_ERGO_ENABLE_FLAG(ShenandoahEvacReserveOverflow);

// If class unloading is globally enabled, aggressive does unloading even with
// concurrent cycles.
if (ClassUnloading) {
SHENANDOAH_ERGO_OVERRIDE_DEFAULT(ShenandoahUnloadClassesFrequency, 1);
}
}

void ShenandoahAggressiveHeuristics::choose_collection_set_from_regiondata(ShenandoahCollectionSet* cset,
Expand All @@ -62,7 +56,7 @@ bool ShenandoahAggressiveHeuristics::should_start_gc() {
}

bool ShenandoahAggressiveHeuristics::should_unload_classes() {
if (!can_unload_classes_normal()) return false;
if (!can_unload_classes()) return false;
if (has_metaspace_oom()) return true;
// Randomly unload classes with 50% chance.
return (os::random() & 1) == 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ ShenandoahHeuristics::ShenandoahHeuristics() :
_gc_time_history(new TruncatedSeq(10, ShenandoahAdaptiveDecayFactor)),
_metaspace_oom()
{
// No unloading during concurrent mark? Communicate that to heuristics
if (!ClassUnloadingWithConcurrentMark) {
FLAG_SET_DEFAULT(ShenandoahUnloadClassesFrequency, 0);
}

size_t num_regions = ShenandoahHeap::heap()->num_regions();
assert(num_regions > 0, "Sanity");

Expand Down Expand Up @@ -262,23 +257,10 @@ bool ShenandoahHeuristics::can_unload_classes() {
return true;
}

bool ShenandoahHeuristics::can_unload_classes_normal() {
if (!can_unload_classes()) return false;
if (has_metaspace_oom()) return true;
if (!ClassUnloadingWithConcurrentMark) return false;
if (ShenandoahUnloadClassesFrequency == 0) return false;
return true;
}

bool ShenandoahHeuristics::should_unload_classes() {
if (!can_unload_classes_normal()) return false;
if (!can_unload_classes()) return false;
if (has_metaspace_oom()) return true;
size_t cycle = ShenandoahHeap::heap()->shenandoah_policy()->cycle_counter();
// Unload classes every Nth GC cycle.
// This should not happen in the same cycle as process_references to amortize costs.
// Offsetting by one is enough to break the rendezvous when periods are equal.
// When periods are not equal, offsetting by one is just as good as any other guess.
return (cycle + 1) % ShenandoahUnloadClassesFrequency == 0;
return ClassUnloadingWithConcurrentMark;
}

void ShenandoahHeuristics::initialize() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ class ShenandoahHeuristics : public CHeapObj<mtGC> {
virtual void choose_collection_set(ShenandoahCollectionSet* collection_set);

virtual bool can_unload_classes();
virtual bool can_unload_classes_normal();
virtual bool should_unload_classes();

virtual const char* name() = 0;
Expand Down
5 changes: 0 additions & 5 deletions src/hotspot/share/gc/shenandoah/shenandoah_globals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,6 @@
" compact - run GC more frequently and with deeper targets to " \
"free up more memory.") \
\
product(uintx, ShenandoahUnloadClassesFrequency, 1, EXPERIMENTAL, \
"Unload the classes every Nth cycle. Normally affects concurrent "\
"GC cycles, as degenerated and full GCs would try to unload " \
"classes regardless. Set to zero to disable class unloading.") \
\
product(uintx, ShenandoahGarbageThreshold, 25, EXPERIMENTAL, \
"How much garbage a region has to contain before it would be " \
"taken for collection. This a guideline only, as GC heuristics " \
Expand Down
4 changes: 0 additions & 4 deletions test/hotspot/jtreg/gc/shenandoah/oom/TestClassLoaderLeak.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,10 @@ public static void main(String[] args) throws Exception {

// Even when concurrent unloading is disabled, Full GC has to recover
passWith("-XX:ShenandoahGCMode=" + mode, "-XX:ShenandoahGCHeuristics=" + h, "-XX:+ClassUnloading", "-XX:-ClassUnloadingWithConcurrentMark");
passWith("-XX:ShenandoahGCMode=" + mode, "-XX:ShenandoahGCHeuristics=" + h, "-XX:+ClassUnloading", "-XX:-ClassUnloadingWithConcurrentMark", "-XX:ShenandoahUnloadClassesFrequency=0");
passWith("-XX:ShenandoahGCMode=" + mode, "-XX:ShenandoahGCHeuristics=" + h, "-XX:+ClassUnloading", "-XX:+ClassUnloadingWithConcurrentMark", "-XX:ShenandoahUnloadClassesFrequency=0");

// Should OOME when unloading forcefully disabled, even if local flags try to enable it back
failWith("-XX:ShenandoahGCMode=" + mode, "-XX:ShenandoahGCHeuristics=" + h, "-XX:-ClassUnloading");
failWith("-XX:ShenandoahGCMode=" + mode, "-XX:ShenandoahGCHeuristics=" + h, "-XX:-ClassUnloading", "-XX:+ClassUnloadingWithConcurrentMark");
failWith("-XX:ShenandoahGCMode=" + mode, "-XX:ShenandoahGCHeuristics=" + h, "-XX:-ClassUnloading", "-XX:+ClassUnloadingWithConcurrentMark", "-XX:ShenandoahUnloadClassesFrequency=1");
failWith("-XX:ShenandoahGCMode=" + mode, "-XX:ShenandoahGCHeuristics=" + h, "-XX:-ClassUnloading", "-XX:-ClassUnloadingWithConcurrentMark", "-XX:ShenandoahUnloadClassesFrequency=1");
}
}
}
Expand Down

1 comment on commit b114a5e

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.