summaryrefslogtreecommitdiffstats
path: root/dex2oat/dex2oat.cc
diff options
context:
space:
mode:
authorAndreas Gampe <agampe@google.com>2016-06-24 14:55:38 -0700
committerAndreas Gampe <agampe@google.com>2016-06-28 20:48:54 -0700
commit25a9abe3cd9594a60d353c0277b4f9e49a71a40a (patch)
tree5cc2e057cd0a1747dea9bbc58c54067657b3b386 /dex2oat/dex2oat.cc
parent7dfe5de0c83a4b7e8f34ae2d5ea47105e620257d (diff)
downloadandroid_art-25a9abe3cd9594a60d353c0277b4f9e49a71a40a.tar.gz
android_art-25a9abe3cd9594a60d353c0277b4f9e49a71a40a.tar.bz2
android_art-25a9abe3cd9594a60d353c0277b4f9e49a71a40a.zip
ART: Add dex2oat swap-usage parameters
Make the dex2oat swap usage decision dependent on parameters that can be changed on the command line. Both the dex file size and dex file count can be modified through the following to new parameters: --swap-dex-size-threshold --swap-dex-count-threshold The defaults remain the same (20MB and 2). Factor out some dex2oat setup code from oat_file_assistant_test and use it in a new dex2oat test. Bug: 29557002 Test: m test-art-host-gtest-dex2oat_test Test: m test-art-host-gtest-oat_file_assistant_test Test: m test-art-host Change-Id: I2814a0b895d960416d20b31c4b0052f98c9cb5e6
Diffstat (limited to 'dex2oat/dex2oat.cc')
-rw-r--r--dex2oat/dex2oat.cc64
1 files changed, 41 insertions, 23 deletions
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index d2b8ba17cc..13d1d0b0fe 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -81,6 +81,9 @@
namespace art {
+static constexpr size_t kDefaultMinDexFilesForSwap = 2;
+static constexpr size_t kDefaultMinDexFileCumulativeSizeForSwap = 20 * MB;
+
static int original_argc;
static char** original_argv;
@@ -351,6 +354,16 @@ NO_RETURN static void Usage(const char* fmt, ...) {
UsageError(" --swap-fd=<file-descriptor>: specifies a file to use for swap (by descriptor).");
UsageError(" Example: --swap-fd=10");
UsageError("");
+ UsageError(" --swap-dex-size-threshold=<size>: specifies the minimum total dex file size in");
+ UsageError(" bytes to allow the use of swap.");
+ UsageError(" Example: --swap-dex-size-threshold=1000000");
+ UsageError(" Default: %zu", kDefaultMinDexFileCumulativeSizeForSwap);
+ UsageError("");
+ UsageError(" --swap-dex-count-threshold=<count>: specifies the minimum number of dex files to");
+ UsageError(" allow the use of swap.");
+ UsageError(" Example: --swap-dex-count-threshold=10");
+ UsageError(" Default: %zu", kDefaultMinDexFilesForSwap);
+ UsageError("");
UsageError(" --app-image-fd=<file-descriptor>: specify output file descriptor for app image.");
UsageError(" Example: --app-image-fd=10");
UsageError("");
@@ -473,25 +486,6 @@ class WatchDog {
pthread_t pthread_;
};
-static constexpr size_t kMinDexFilesForSwap = 2;
-static constexpr size_t kMinDexFileCumulativeSizeForSwap = 20 * MB;
-
-static bool UseSwap(bool is_image, std::vector<const DexFile*>& dex_files) {
- if (is_image) {
- // Don't use swap, we know generation should succeed, and we don't want to slow it down.
- return false;
- }
- if (dex_files.size() < kMinDexFilesForSwap) {
- // If there are less dex files than the threshold, assume it's gonna be fine.
- return false;
- }
- size_t dex_files_size = 0;
- for (const auto* dex_file : dex_files) {
- dex_files_size += dex_file->GetHeader().file_size_;
- }
- return dex_files_size >= kMinDexFileCumulativeSizeForSwap;
-}
-
class Dex2Oat FINAL {
public:
explicit Dex2Oat(TimingLogger* timings) :
@@ -1138,6 +1132,16 @@ class Dex2Oat FINAL {
swap_file_name_ = option.substr(strlen("--swap-file=")).data();
} else if (option.starts_with("--swap-fd=")) {
ParseUintOption(option, "--swap-fd", &swap_fd_, Usage);
+ } else if (option.starts_with("--swap-dex-size-threshold=")) {
+ ParseUintOption(option,
+ "--swap-dex-size-threshold",
+ &min_dex_file_cumulative_size_for_swap_,
+ Usage);
+ } else if (option.starts_with("--swap-dex-count-threshold=")) {
+ ParseUintOption(option,
+ "--swap-dex-count-threshold",
+ &min_dex_files_for_swap_,
+ Usage);
} else if (option.starts_with("--app-image-file=")) {
app_image_file_name_ = option.substr(strlen("--app-image-file=")).data();
} else if (option.starts_with("--app-image-fd=")) {
@@ -1848,10 +1852,6 @@ class Dex2Oat FINAL {
}
}
- CompilerOptions* GetCompilerOptions() const {
- return compiler_options_.get();
- }
-
bool IsImage() const {
return IsAppImage() || IsBootImage();
}
@@ -1903,6 +1903,22 @@ class Dex2Oat FINAL {
}
private:
+ bool UseSwap(bool is_image, const std::vector<const DexFile*>& dex_files) {
+ if (is_image) {
+ // Don't use swap, we know generation should succeed, and we don't want to slow it down.
+ return false;
+ }
+ if (dex_files.size() < min_dex_files_for_swap_) {
+ // If there are less dex files than the threshold, assume it's gonna be fine.
+ return false;
+ }
+ size_t dex_files_size = 0;
+ for (const auto* dex_file : dex_files) {
+ dex_files_size += dex_file->GetHeader().file_size_;
+ }
+ return dex_files_size >= min_dex_file_cumulative_size_for_swap_;
+ }
+
template <typename T>
static std::vector<T*> MakeNonOwningPointerVector(const std::vector<std::unique_ptr<T>>& src) {
std::vector<T*> result;
@@ -2490,6 +2506,8 @@ class Dex2Oat FINAL {
bool dump_slow_timing_;
std::string swap_file_name_;
int swap_fd_;
+ size_t min_dex_files_for_swap_ = kDefaultMinDexFilesForSwap;
+ size_t min_dex_file_cumulative_size_for_swap_ = kDefaultMinDexFileCumulativeSizeForSwap;
std::string app_image_file_name_;
int app_image_fd_;
std::string profile_file_;