diff options
author | 2023-07-11 10:26:52 +0100 | |
---|---|---|
committer | 2023-07-11 10:51:55 +0000 | |
commit | 45710e71e371ec4c26c4a5b105f42d9db873099b (patch) | |
tree | bab648430d6fbc3c88fee2953036bd35ea948002 | |
parent | db9deaf6695ec111eb154f3dcf2a043d63043a70 (diff) |
Add a new option -XX:+DisableEagerlyReleaseExplicitGC.
And use it by default in the 'art' script for benchmarking. This ensures
we can better track performance bottlenecks exposed by benchmarks.
Test: test.py
Change-Id: Ib37e5e1d2d4e5d13ab50392e3217f43ee8fe35e1
-rw-r--r-- | runtime/gc/collector/garbage_collector.cc | 3 | ||||
-rw-r--r-- | runtime/parsed_options.cc | 2 | ||||
-rw-r--r-- | runtime/runtime.cc | 3 | ||||
-rw-r--r-- | runtime/runtime.h | 5 | ||||
-rw-r--r-- | runtime/runtime_options.def | 1 | ||||
-rwxr-xr-x | tools/art | 8 |
6 files changed, 18 insertions, 4 deletions
diff --git a/runtime/gc/collector/garbage_collector.cc b/runtime/gc/collector/garbage_collector.cc index f35be96625..6eacf2c900 100644 --- a/runtime/gc/collector/garbage_collector.cc +++ b/runtime/gc/collector/garbage_collector.cc @@ -321,7 +321,8 @@ bool GarbageCollector::ShouldEagerlyReleaseMemoryToOS() const { if (runtime->IsZygote()) { return true; } - if (GetCurrentIteration()->GetGcCause() == kGcCauseExplicit) { + if (GetCurrentIteration()->GetGcCause() == kGcCauseExplicit && + !runtime->IsEagerlyReleaseExplicitGcDisabled()) { // Our behavior with explicit GCs is to always release any available memory. return true; } diff --git a/runtime/parsed_options.cc b/runtime/parsed_options.cc index 7df765fe29..140503fd36 100644 --- a/runtime/parsed_options.cc +++ b/runtime/parsed_options.cc @@ -341,6 +341,8 @@ std::unique_ptr<RuntimeParser> ParsedOptions::MakeParser(bool ignore_unrecognize .IntoKey(M::BackgroundGc) .Define("-XX:+DisableExplicitGC") .IntoKey(M::DisableExplicitGC) + .Define("-XX:+DisableEagerlyReleaseExplicitGC") + .IntoKey(M::DisableEagerlyReleaseExplicitGC) .Define("-Xlockprofthreshold:_") .WithType<unsigned int>() .IntoKey(M::LockProfThreshold) diff --git a/runtime/runtime.cc b/runtime/runtime.cc index 62f6a1327d..5c86a81f93 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -250,6 +250,7 @@ Runtime::Runtime() must_relocate_(false), is_concurrent_gc_enabled_(true), is_explicit_gc_disabled_(false), + is_eagerly_release_explicit_gc_disabled_(false), image_dex2oat_enabled_(true), default_stack_size_(0), heap_(nullptr), @@ -1504,6 +1505,8 @@ bool Runtime::Init(RuntimeArgumentMap&& runtime_options_in) { is_zygote_ = runtime_options.Exists(Opt::Zygote); is_primary_zygote_ = runtime_options.Exists(Opt::PrimaryZygote); is_explicit_gc_disabled_ = runtime_options.Exists(Opt::DisableExplicitGC); + is_eagerly_release_explicit_gc_disabled_ = + runtime_options.Exists(Opt::DisableEagerlyReleaseExplicitGC); image_dex2oat_enabled_ = runtime_options.GetOrDefault(Opt::ImageDex2Oat); dump_native_stack_on_sig_quit_ = runtime_options.GetOrDefault(Opt::DumpNativeStackOnSigQuit); allow_in_memory_compilation_ = runtime_options.Exists(Opt::AllowInMemoryCompilation); diff --git a/runtime/runtime.h b/runtime/runtime.h index fc8c050cf1..335ba546ab 100644 --- a/runtime/runtime.h +++ b/runtime/runtime.h @@ -217,6 +217,10 @@ class Runtime { return is_explicit_gc_disabled_; } + bool IsEagerlyReleaseExplicitGcDisabled() const { + return is_eagerly_release_explicit_gc_disabled_; + } + std::string GetCompilerExecutable() const; const std::vector<std::string>& GetCompilerOptions() const { @@ -1260,6 +1264,7 @@ class Runtime { bool must_relocate_; bool is_concurrent_gc_enabled_; bool is_explicit_gc_disabled_; + bool is_eagerly_release_explicit_gc_disabled_; bool image_dex2oat_enabled_; std::string compiler_executable_; diff --git a/runtime/runtime_options.def b/runtime/runtime_options.def index b2fcf7df13..d4e074273f 100644 --- a/runtime/runtime_options.def +++ b/runtime/runtime_options.def @@ -117,6 +117,7 @@ RUNTIME_OPTIONS_KEY (Memory<1>, LargeObjectThreshold, gc::He RUNTIME_OPTIONS_KEY (BackgroundGcOption, BackgroundGc) RUNTIME_OPTIONS_KEY (Unit, DisableExplicitGC) +RUNTIME_OPTIONS_KEY (Unit, DisableEagerlyReleaseExplicitGC) RUNTIME_OPTIONS_KEY (Unit, NoSigChain) RUNTIME_OPTIONS_KEY (Unit, ForceNativeBridge) RUNTIME_OPTIONS_KEY (LogVerbosity, Verbose) @@ -330,9 +330,11 @@ ALLOW_DEFAULT_JDWP="no" VERBOSE="no" CLEAN_OAT_FILES="yes" RUN_DEX2OAT="yes" -# 'art' script is for benchmarking, so override default JIT thresholds that are -# too conservative for benchmarking. -EXTRA_OPTIONS=(-Xjitwarmupthreshold:4000 -Xjitthreshold:10000) +# 'art' script is for benchmarking, so override: +# - default JIT thresholds that are too conservative for benchmarking +# - the eagerly releasing memory to the OS on explicit GC, which is more suited +# for multi-apps execution than benchmarks. +EXTRA_OPTIONS=(-Xjitwarmupthreshold:4000 -Xjitthreshold:10000 -XX:+DisableEagerlyReleaseExplicitGC) DEX2OAT_FLAGS=() DEX2OAT_CLASSPATH=() GENERATE_APP_IMAGE="no" |