From 04ff226764b125c79a0bf41e571c8311bac8a868 Mon Sep 17 00:00:00 2001 From: Calin Juravle Date: Wed, 2 Apr 2014 19:08:47 +0100 Subject: Profile: renamed kThresholdPercent and make it configurable Bug: 12877748 Change-Id: If266f20f77faad4a726ef8df451a0c42f541392f --- compiler/driver/compiler_driver.cc | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) (limited to 'compiler/driver/compiler_driver.cc') diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index 5c790be..7fadfc9 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) { @@ -2045,7 +2049,7 @@ bool CompilerDriver::ReadProfile(const std::string& filename) { std::vector 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. @@ -2054,8 +2058,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>> ProfileSet; ProfileSet countSet; while (!in.eof()) { @@ -2083,12 +2087,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(curTotalCount) / static_cast(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; @@ -2100,8 +2104,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); @@ -2111,15 +2124,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; } -- cgit v1.1