// Minimum number of new methods/classes that profiles // must contain to enable recompilation. static constexpr const uint32_t kMinNewMethodsForCompilation = 100; static constexpr const uint32_t kMinNewClassesForCompilation = 50;
// Load the reference profile. if (!info.Load(reference_profile_file->Fd(), /*merge_classes=*/ true, filter_fn)) {
LOG(WARNING) << "Could not load reference profile file"; return ProfmanResult::kErrorBadProfiles;
}
if (options.IsBootImageMerge() && !info.IsForBootImage()) {
LOG(WARNING) << "Requested merge for boot image profile but the reference profile is regular."; return ProfmanResult::kErrorBadProfiles;
}
// Store the current state of the reference profile before merging with the current profiles.
uint32_t number_of_methods = info.GetNumberOfMethods();
uint32_t number_of_classes = info.GetNumberOfResolvedClasses();
// Merge all current profiles. for (size_t i = 0; i < profile_files.size(); i++) {
ProfileCompilationInfo cur_info(options.IsBootImageMerge()); if (!cur_info.Load(profile_files[i]->Fd(), /*merge_classes=*/ true, filter_fn)) {
LOG(WARNING) << "Could not load profile file at index " << i; if (options.IsForceMerge() || options.IsForceMergeAndAnalyze()) { // If we have to merge forcefully, ignore load failures. // This is useful for boot image profiles to ignore stale profiles which are // cleared lazily. continue;
} // TODO: Do we really need to use a different error code for version mismatch?
ProfileCompilationInfo wrong_info(!options.IsBootImageMerge()); if (wrong_info.Load(profile_files[i]->Fd(), /*merge_classes=*/ true, filter_fn)) { return ProfmanResult::kErrorDifferentVersions;
} return ProfmanResult::kErrorBadProfiles;
}
if (!info.MergeWith(cur_info)) {
LOG(WARNING) << "Could not merge profile file at index " << i; return ProfmanResult::kErrorBadProfiles;
}
}
// If we perform a forced merge do not analyze the difference between profiles. if (!options.IsForceMerge()) { if (info.IsEmpty()) { return ProfmanResult::kSkipCompilationEmptyProfiles;
}
if (options.IsForceMergeAndAnalyze()) { // When we force merge and analyze, we want to always recompile unless there is absolutely no // difference between before and after the merge (i.e., the classes and methods in the // reference profile were already a superset of those in all current profiles before the // merge.) if (info.GetNumberOfMethods() == number_of_methods &&
info.GetNumberOfResolvedClasses() == number_of_classes) { return ProfmanResult::kSkipCompilationSmallDelta;
}
} else {
uint32_t min_change_in_methods_for_compilation = std::max(
(options.GetMinNewMethodsPercentChangeForCompilation() * number_of_methods) / 100,
kMinNewMethodsForCompilation);
uint32_t min_change_in_classes_for_compilation = std::max(
(options.GetMinNewClassesPercentChangeForCompilation() * number_of_classes) / 100,
kMinNewClassesForCompilation); // Check if there is enough new information added by the current profiles. if (((info.GetNumberOfMethods() - number_of_methods) <
min_change_in_methods_for_compilation) &&
((info.GetNumberOfResolvedClasses() - number_of_classes) <
min_change_in_classes_for_compilation)) { return ProfmanResult::kSkipCompilationSmallDelta;
}
}
}
// We were successful in merging all profile information. Update the reference profile. if (!reference_profile_file->ClearContent()) {
PLOG(WARNING) << "Could not clear reference profile file"; return ProfmanResult::kErrorIO;
} if (!info.Save(reference_profile_file->Fd())) {
LOG(WARNING) << "Could not save reference profile file"; return ProfmanResult::kErrorIO;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.