summaryrefslogtreecommitdiffstats
path: root/compiler/driver
diff options
context:
space:
mode:
authorCalin Juravle <calin@google.com>2014-04-03 09:01:40 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2014-04-03 09:01:41 +0000
commit5cc2d076cb7854ec2327895e5586f4cbe5e3ee70 (patch)
treea8b176cb11ad1f062c4d3fa4c8e7d3ea29ae90b1 /compiler/driver
parent317055b5a75f84c09647f099efe766708da5bfb8 (diff)
parent04ff226764b125c79a0bf41e571c8311bac8a868 (diff)
downloadart-5cc2d076cb7854ec2327895e5586f4cbe5e3ee70.tar.gz
art-5cc2d076cb7854ec2327895e5586f4cbe5e3ee70.tar.bz2
art-5cc2d076cb7854ec2327895e5586f4cbe5e3ee70.zip
Merge "Profile: renamed kThresholdPercent and make it configurable"
Diffstat (limited to 'compiler/driver')
-rw-r--r--compiler/driver/compiler_driver.cc36
1 files changed, 25 insertions, 11 deletions
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index 15d27a7f9..fc1332a55 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -59,6 +59,10 @@
#include "verifier/method_verifier.h"
#include "verifier/method_verifier-inl.h"
+#ifdef HAVE_ANDROID_OS
+#include "cutils/properties.h"
+#endif
+
namespace art {
static double Percentage(size_t x, size_t y) {
@@ -2052,7 +2056,7 @@ bool CompilerDriver::ReadProfile(const std::string& filename) {
std::vector<std::string> summary_info;
Split(line, '/', summary_info);
if (summary_info.size() != 3) {
- // Bad summary info. It should be count/total/bootpath
+ // Bad summary info. It should be count/total/bootpath.
return false;
}
// This is the number of hits in all methods.
@@ -2061,8 +2065,8 @@ bool CompilerDriver::ReadProfile(const std::string& filename) {
total_count += atoi(summary_info[i].c_str());
}
- // Now read each line until the end of file. Each line consists of 3 fields separated by /
- // Store the info in desceding order given by the most used methods
+ // Now read each line until the end of file. Each line consists of 3 fields separated by '/'.
+ // Store the info in descending order given by the most used methods.
typedef std::set<std::pair<int, std::vector<std::string>>> ProfileSet;
ProfileSet countSet;
while (!in.eof()) {
@@ -2090,12 +2094,12 @@ bool CompilerDriver::ReadProfile(const std::string& filename) {
double usedPercent = (count * 100.0) / total_count;
curTotalCount += count;
- // Methods with the same count should be part of the same top K percentage bucket
+ // Methods with the same count should be part of the same top K percentage bucket.
double topKPercentage = (prevData != nullptr) && (prevData->GetCount() == count)
? prevData->GetTopKUsedPercentage()
: 100 * static_cast<double>(curTotalCount) / static_cast<double>(total_count);
- // Add it to the profile map
+ // Add it to the profile map.
ProfileData curData = ProfileData(methodname, count, size, usedPercent, topKPercentage);
profile_map_[methodname] = curData;
prevData = &curData;
@@ -2107,8 +2111,17 @@ bool CompilerDriver::SkipCompilation(const std::string& method_name) {
if (!profile_ok_) {
return true;
}
- // Methods that comprise kThresholdPercent % of the total samples will be compiled
- constexpr double kThresholdPercent = 90.0;
+ // Methods that comprise topKPercentThreshold % of the total samples will be compiled.
+ double topKPercentThreshold = 90.0;
+#ifdef HAVE_ANDROID_OS
+ char buf[PROP_VALUE_MAX];
+ property_get("dalvik.vm.profile.compile_thr", buf, "90.0");
+ topKPercentThreshold = strtod(buf, nullptr);
+#endif
+ // Test for reasonable thresholds.
+ if (topKPercentThreshold < 10.0 || topKPercentThreshold > 90.0) {
+ topKPercentThreshold = 90.0;
+ }
// First find the method in the profile map.
ProfileMap::iterator i = profile_map_.find(method_name);
@@ -2118,15 +2131,16 @@ bool CompilerDriver::SkipCompilation(const std::string& method_name) {
return true;
}
const ProfileData& data = i->second;
+
// Compare against the start of the topK percentage bucket just in case the threshold
- // falls inside a bucket
- bool compile = data.GetTopKUsedPercentage() - data.GetUsedPercent() <= kThresholdPercent;
+ // falls inside a bucket.
+ bool compile = data.GetTopKUsedPercentage() - data.GetUsedPercent() <= topKPercentThreshold;
if (compile) {
LOG(INFO) << "compiling method " << method_name << " because its usage is part of top "
<< data.GetTopKUsedPercentage() << "% with a percent of " << data.GetUsedPercent() << "%";
} else {
- VLOG(compiler) << "not compiling method " << method_name << " because usage is too low ("
- << data.GetUsedPercent() << "%)";
+ VLOG(compiler) << "not compiling method " << method_name << " because it's not part of leading "
+ << topKPercentThreshold << "% samples)";
}
return !compile;
}