Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ergonomics Profile #9

Draft
wants to merge 35 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
e84d698
Add option for dedicated ergonomics profile
Jul 17, 2023
9cea06f
change gb
Jul 17, 2023
f58c9cd
change gb to prevent overflow
Jul 17, 2023
e8e0324
test G
Jul 24, 2023
b84eba2
use G
Jul 24, 2023
765fc11
add GC selection for dedicated ergonomics profile
Jul 25, 2023
0bb062e
fix oopsie
Jul 25, 2023
5bc7f7e
wip
brunoborges Aug 7, 2023
08cc6ce
Remove auto import
brunoborges Aug 7, 2023
b254d08
Real world doc for ErgonomicsProfile flag
brunoborges Aug 7, 2023
b5ff702
Remove leading whitespace
brunoborges Aug 7, 2023
5768a4a
Validate ergonomic profile in a function
brunoborges Aug 7, 2023
613c117
Fix where we set the sys property
brunoborges Aug 7, 2023
6559389
Store after it may have been changed
brunoborges Aug 7, 2023
93cad80
Set the profile before the flags
brunoborges Aug 7, 2023
92c1df1
Minor fixes
brunoborges Aug 8, 2023
d8a19e6
No need to change MinRAMPercentage here.
brunoborges Aug 8, 2023
a7c5576
Remove unnecessary new line
brunoborges Aug 8, 2023
34fa5de
Merge branch 'main' into ergonomics-profile
brunoborges Oct 6, 2023
6fd0069
Expose selected GC name through JMX
brunoborges Oct 6, 2023
ce6d869
Merge branch 'master' into ergonomics-profile
brunoborges Apr 9, 2024
0bcc5b3
Merge remote-tracking branch 'upstream/master' into ergonomics-profile
brunoborges Apr 25, 2024
eafd4f4
use auto by default
brunoborges Apr 25, 2024
436ba32
missing qupte
brunoborges Apr 25, 2024
a0199e4
simplified
brunoborges Apr 26, 2024
439bae6
jtreg test for ergo profile
brunoborges Apr 26, 2024
9c4b3ec
test max ram percentage
brunoborges Apr 28, 2024
a7db925
Tests for ergo profiles
brunoborges Apr 29, 2024
4cd37d0
Do not consider ZGC for now
brunoborges May 8, 2024
6232c64
Remove getGCName API from Runtime MBean and VMManagement
brunoborges May 9, 2024
fc3e25b
Update src/hotspot/share/gc/shared/gcConfig.cpp
brunoborges May 10, 2024
7aa4ec5
ZGC is not part of initial implementation
brunoborges May 10, 2024
63bc938
ZGC is not part of initial implementation
brunoborges May 10, 2024
92fad0c
merge
brunoborges May 10, 2024
da546d2
Add AutoErgonomicsProfile bool flag to enable auto selection
brunoborges May 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 29 additions & 6 deletions src/hotspot/share/gc/shared/gcConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,41 @@ void GCConfig::fail_if_non_included_gc_is_selected() {
}

void GCConfig::select_gc_ergonomically() {
if (os::is_server_class_machine()) {
if (strcmp(ErgonomicsProfile, "shared") == 0) {
if (os::is_server_class_machine()) {
#if INCLUDE_G1GC
FLAG_SET_ERGO_IF_DEFAULT(UseG1GC, true);
FLAG_SET_ERGO_IF_DEFAULT(UseG1GC, true);
brunoborges marked this conversation as resolved.
Show resolved Hide resolved
#elif INCLUDE_PARALLELGC
FLAG_SET_ERGO_IF_DEFAULT(UseParallelGC, true);
FLAG_SET_ERGO_IF_DEFAULT(UseParallelGC, true);
#elif INCLUDE_SERIALGC
FLAG_SET_ERGO_IF_DEFAULT(UseSerialGC, true);
FLAG_SET_ERGO_IF_DEFAULT(UseSerialGC, true);
#endif
} else {
} else {
#if INCLUDE_SERIALGC
FLAG_SET_ERGO_IF_DEFAULT(UseSerialGC, true);
#endif
}
} else if (strcmp(ErgonomicsProfile, "dedicated") == 0) {
julong phys_mem = os::physical_memory();
if (os::active_processor_count() <= 1) {
#if INCLUDE_SERIALGC
FLAG_SET_ERGO_IF_DEFAULT(UseSerialGC, true);
FLAG_SET_ERGO_IF_DEFAULT(UseSerialGC, true);
#endif
} else if (phys_mem >= 16*G){
#if INCLUDE_ZGC
FLAG_SET_ERGO_IF_DEFAULT(UseZGC, true);
#endif
} else if (phys_mem > 2048*M){
#if INCLUDE_G1GC
FLAG_SET_ERGO_IF_DEFAULT(UseG1GC, true);
#endif
} else {
#if INCLUDE_PARALLELGC
FLAG_SET_ERGO_IF_DEFAULT(UseParallelGC, true);
#endif
}
} else {
ShouldNotReachHere();
}
}

Expand Down
6 changes: 6 additions & 0 deletions src/hotspot/share/gc/shared/gc_globals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@
product(bool, UseShenandoahGC, false, \
"Use the Shenandoah garbage collector") \
\
product(ccstr, ErgonomicsProfile, "shared", \
"Ergonomics profile to use. " \
"Options include \"shared\" for when the JVM is running " \
"in a shared environment and \"dedicated\" for when the " \
"JVM is running on a system with dedicated resources") \
brunoborges marked this conversation as resolved.
Show resolved Hide resolved
\
/* notice: the max range value here is INT_MAX not UINT_MAX */ \
/* to protect from overflows */ \
product(uint, ParallelGCThreads, 0, \
Expand Down
37 changes: 37 additions & 0 deletions src/hotspot/share/runtime/arguments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@
#if INCLUDE_JFR
#include "jfr/jfr.hpp"
#endif
#ifdef LINUX
#include "osContainer_linux.hpp"
#endif

#include <limits>

Expand Down Expand Up @@ -1514,6 +1517,22 @@ jint Arguments::set_ergonomics_flags() {
return JNI_OK;
}

void Arguments::set_ergonomics_profile() {
if (FLAG_IS_DEFAULT(ErgonomicsProfile)){

#ifdef LINUX
if (OSContainer::is_containerized()){
FLAG_SET_ERGO(ErgonomicsProfile, "dedicated");
}
brunoborges marked this conversation as resolved.
Show resolved Hide resolved
#endif //LINUX

} else {
if (strcmp(ErgonomicsProfile, "shared") != 0 && strcmp(ErgonomicsProfile, "dedicated") != 0) {
brunoborges marked this conversation as resolved.
Show resolved Hide resolved
vm_exit_during_initialization(err_msg("Unsupported ErgonomicsProfile: %s", ErgonomicsProfile));
}
}
}

size_t Arguments::limit_heap_by_allocatable_memory(size_t limit) {
size_t max_allocatable;
size_t result = limit;
Expand Down Expand Up @@ -1561,6 +1580,22 @@ void Arguments::set_heap_size() {
: (julong)MaxRAM;
}

// Update default heap size for dedicated ergonomics profile
brunoborges marked this conversation as resolved.
Show resolved Hide resolved
if (strcmp(ErgonomicsProfile, "dedicated") == 0) {
FLAG_SET_DEFAULT(MinRAMPercentage, 25.0);
brunoborges marked this conversation as resolved.
Show resolved Hide resolved
FLAG_SET_DEFAULT(InitialRAMPercentage, 50.0);
if (phys_mem >= 16*G){
FLAG_SET_DEFAULT(MaxRAMPercentage, 90.0);
} else if (phys_mem >= 6*G){
FLAG_SET_DEFAULT(MaxRAMPercentage, 85.0);
} else if (phys_mem >= 4*G){
FLAG_SET_DEFAULT(MaxRAMPercentage, 80.0);
} else if (phys_mem >= 0.5*G){
FLAG_SET_DEFAULT(MaxRAMPercentage, 75.0);
} else {
FLAG_SET_DEFAULT(MaxRAMPercentage, 50.0);
}
}

// Convert deprecated flags
if (FLAG_IS_DEFAULT(MaxRAMPercentage) &&
Expand Down Expand Up @@ -3981,6 +4016,8 @@ jint Arguments::apply_ergo() {
jint result = set_ergonomics_flags();
if (result != JNI_OK) return result;

set_ergonomics_profile();

// Set heap size based on available physical memory
set_heap_size();

Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/runtime/arguments.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ class Arguments : AllStatic {
static bool _ClipInlining;

// GC ergonomics
static void set_ergonomics_profile();
static void set_conservative_max_heap_alignment();
static void set_use_compressed_oops();
static void set_use_compressed_klass_ptrs();
Expand Down