From 998c21661b5074c293cae818d0ab7c44dcda3a66 Mon Sep 17 00:00:00 2001 From: Calin Juravle Date: Mon, 21 Dec 2015 15:39:33 +0200 Subject: Perform profile file analysis in dex2oat Dex2oat can accept now multiple profile files to drive a profile based compilation. --profile-file and --reference-profile-file speficy a pair of profile files which will be evaluated for significant differences before starting the compilation. If the difference is insignificant (according to some internal metric) the compilation is skipped and a message is logged. Multiple pairs of --profile-file and --reference-profile-file can be specified. This effectively enables multi user support since profiles for different users will be kept separately. --reference-profile-file can be left out, case in which the decision is solely based on --profile-file. If both flags are present, then their repetition should form unique pairs. If the compilation is performed and --reference-profile-file is given then its data is merged with the data from the corresponding --profile- file and saved back to the file. If no profile flags are given, dex2oat proceeds as before and compiles the dex files unconditionally. As part of this change - merge ProfileCompilationInfo and OfflineProfilingInfo under the same object. There was no use to keep them separate anymore. - SaveProfilingInfo now merges the data with what was in the file before instead of overwriting it. Bug: 26080105 Change-Id: Ia8c8b55587d468bca5179f78941854285426234d --- compiler/driver/compiler_driver.cc | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) (limited to 'compiler/driver/compiler_driver.cc') diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index afb4b71ccf..043bd93bd7 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -347,8 +347,8 @@ CompilerDriver::CompilerDriver( size_t thread_count, bool dump_stats, bool dump_passes, const std::string& dump_cfg_file_name, bool dump_cfg_append, CumulativeLogger* timer, int swap_fd, - const std::string& profile_file, - const std::unordered_map* dex_to_oat_map) + const std::unordered_map* dex_to_oat_map, + const ProfileCompilationInfo* profile_compilation_info) : compiler_options_(compiler_options), verification_results_(verification_results), method_inliner_map_(method_inliner_map), @@ -377,7 +377,8 @@ CompilerDriver::CompilerDriver( support_boot_image_fixup_(instruction_set != kMips && instruction_set != kMips64), dex_files_for_oat_file_(nullptr), dex_file_oat_filename_map_(dex_to_oat_map), - compiled_method_storage_(swap_fd) { + compiled_method_storage_(swap_fd), + profile_compilation_info_(profile_compilation_info) { DCHECK(compiler_options_ != nullptr); DCHECK(verification_results_ != nullptr); DCHECK(method_inliner_map_ != nullptr); @@ -385,12 +386,6 @@ CompilerDriver::CompilerDriver( compiler_->Init(); CHECK_EQ(boot_image_, image_classes_.get() != nullptr); - - // Read the profile file if one is provided. - if (!profile_file.empty()) { - profile_compilation_info_.reset(new ProfileCompilationInfo(profile_file)); - LOG(INFO) << "Using profile data from file " << profile_file; - } } CompilerDriver::~CompilerDriver() { @@ -2306,15 +2301,11 @@ void CompilerDriver::InitializeClasses(jobject class_loader, void CompilerDriver::Compile(jobject class_loader, const std::vector& dex_files, ThreadPool* thread_pool, TimingLogger* timings) { - if (profile_compilation_info_ != nullptr) { - if (!profile_compilation_info_->Load(dex_files)) { - LOG(WARNING) << "Failed to load offline profile info from " - << profile_compilation_info_->GetFilename() - << ". No methods will be compiled"; - } else if (kDebugProfileGuidedCompilation) { - LOG(INFO) << "[ProfileGuidedCompilation] " - << profile_compilation_info_->DumpInfo(); - } + if (kDebugProfileGuidedCompilation) { + LOG(INFO) << "[ProfileGuidedCompilation] " << + ((profile_compilation_info_ == nullptr) + ? "null" + : profile_compilation_info_->DumpInfo(&dex_files)); } for (size_t i = 0; i != dex_files.size(); ++i) { const DexFile* dex_file = dex_files[i]; -- cgit v1.2.3-59-g8ed1b