Skip to content

Commit

Permalink
ART: Tuning compiler thread count for application runtime
Browse files Browse the repository at this point in the history
dex2oat decides the number of compiler threads to be spawned based
on the number of cores in the system. Using this max possible compiler
threads causes over parallelization on some platforms and there by
leads to longer install times. Reducing to fewer threads on these
platforms, improves this time by 60% to 100%.
Some APPs will call dex2oat at the first launch time(runtime). The
thread count tuning is needed for such scenario.

Change-Id: Id3a545f0300f93397627beeb697a7b7cfd912d52
  • Loading branch information
Chitti Babu Theegala authored and Linux Build Service Account committed Oct 6, 2015
1 parent 048801b commit c06972f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions dex2oat/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ include art/build/Android.executable.mk
DEX2OAT_SRC_FILES := \
dex2oat.cc

ifeq ($$(art_target_or_host),target)
LOCAL_SHARED_LIBRARIES += libcutils
endif

# TODO: Remove this when the framework (installd) supports pushing the
# right instruction-set parameter for the primary architecture.
ifneq ($(filter ro.zygote=zygote64,$(PRODUCT_DEFAULT_PROPERTY_OVERRIDES)),)
Expand Down
15 changes: 15 additions & 0 deletions dex2oat/dex2oat.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@
#include "vector_output_stream.h"
#include "well_known_classes.h"
#include "zip_archive.h"
#ifdef HAVE_ANDROID_OS
#include "cutils/properties.h"
#endif

namespace art {

Expand Down Expand Up @@ -841,6 +844,18 @@ class Dex2Oat FINAL {
}
}

// Override the number of compiler threads with optimal value (thru system property)
#ifdef HAVE_ANDROID_OS
const char* propertyName = "ro.sys.fw.dex2oat_thread_count";
char thread_count_str[PROPERTY_VALUE_MAX];

if (property_get(propertyName, thread_count_str, "") > 0) {
if (ParseUint(thread_count_str, &thread_count_)) {
LOG(INFO) << "Adjusted thread count (for runtime dex2oat): " << thread_count_ << ", " << thread_count_str;
}
}
#endif

image_ = (!image_filename_.empty());
if (!requested_specific_compiler && !kUseOptimizingCompiler) {
// If no specific compiler is requested, the current behavior is
Expand Down

0 comments on commit c06972f

Please sign in to comment.