Revert^2 "Increase threshold for profile compilation"
Increase threshold for profile compilation
Threshold to trigger compilation based on profiles has been increase
to avoid re-compilation too frequenctly.
Now compilation will take place if methods/classes in the new profile exceeds
by maximum of the following:
- 2% methods/classes in the existing profile.
- 100 methods or 50 classes.
Context for above numbers:
I analyzed profiles on my local device. Average number of methods and classes
in the profiles were 8000 and 2500 respectively.
Also added tests for the same.
Bug: 66732454
Test: test-art-[host|target]-gtest-profile_assistant_test
This reverts commit a660171d8fbf907def7720b2af5e045081f11094.
Change-Id: I5c5f8d76a32900c42cda21052636a8588d28e521
diff --git a/profman/profile_assistant_test.cc b/profman/profile_assistant_test.cc
index 8cbf8c3..73724b2 100644
--- a/profman/profile_assistant_test.cc
+++ b/profman/profile_assistant_test.cc
@@ -335,6 +335,46 @@
ASSERT_EQ(expected_clases.size(), found);
}
+ int CheckCompilationMethodPercentChange(uint16_t methods_in_cur_profile,
+ uint16_t methods_in_ref_profile) {
+ ScratchFile profile;
+ ScratchFile reference_profile;
+ std::vector<int> profile_fds({ GetFd(profile)});
+ int reference_profile_fd = GetFd(reference_profile);
+ std::vector<uint32_t> hot_methods_cur;
+ std::vector<uint32_t> hot_methods_ref;
+ std::vector<uint32_t> empty_vector;
+ for (size_t i = 0; i < methods_in_cur_profile; ++i) {
+ hot_methods_cur.push_back(i);
+ }
+ for (size_t i = 0; i < methods_in_ref_profile; ++i) {
+ hot_methods_ref.push_back(i);
+ }
+ ProfileCompilationInfo info1;
+ uint16_t methods_in_profile = std::max(methods_in_cur_profile, methods_in_ref_profile);
+ SetupBasicProfile("p1", 1, methods_in_profile, hot_methods_cur, empty_vector, empty_vector,
+ profile, &info1);
+ ProfileCompilationInfo info2;
+ SetupBasicProfile("p1", 1, methods_in_profile, hot_methods_ref, empty_vector, empty_vector,
+ reference_profile, &info2);
+ return ProcessProfiles(profile_fds, reference_profile_fd);
+ }
+
+ int CheckCompilationClassPercentChange(uint16_t classes_in_cur_profile,
+ uint16_t classes_in_ref_profile) {
+ ScratchFile profile;
+ ScratchFile reference_profile;
+
+ std::vector<int> profile_fds({ GetFd(profile)});
+ int reference_profile_fd = GetFd(reference_profile);
+
+ ProfileCompilationInfo info1;
+ SetupProfile("p1", 1, 0, classes_in_cur_profile, profile, &info1);
+ ProfileCompilationInfo info2;
+ SetupProfile("p1", 1, 0, classes_in_ref_profile, reference_profile, &info2);
+ return ProcessProfiles(profile_fds, reference_profile_fd);
+ }
+
std::unique_ptr<ArenaAllocator> arena_;
// Cache of inline caches generated during tests.
@@ -460,7 +500,7 @@
GetFd(profile2)});
int reference_profile_fd = GetFd(reference_profile);
- const uint16_t kNumberOfMethodsToSkipCompilation = 1;
+ const uint16_t kNumberOfMethodsToSkipCompilation = 24; // Threshold is 100.
ProfileCompilationInfo info1;
SetupProfile("p1", 1, kNumberOfMethodsToSkipCompilation, 0, profile1, &info1);
ProfileCompilationInfo info2;
@@ -489,6 +529,42 @@
CheckProfileInfo(profile2, info2);
}
+TEST_F(ProfileAssistantTest, DoNotAdviseCompilationMethodPercentage) {
+ const uint16_t kNumberOfMethodsInRefProfile = 6000;
+ const uint16_t kNumberOfMethodsInCurProfile = 6100; // Threshold is 2%.
+ // We should not advise compilation.
+ ASSERT_EQ(ProfileAssistant::kSkipCompilation,
+ CheckCompilationMethodPercentChange(kNumberOfMethodsInCurProfile,
+ kNumberOfMethodsInRefProfile));
+}
+
+TEST_F(ProfileAssistantTest, ShouldAdviseCompilationMethodPercentage) {
+ const uint16_t kNumberOfMethodsInRefProfile = 6000;
+ const uint16_t kNumberOfMethodsInCurProfile = 6200; // Threshold is 2%.
+ // We should advise compilation.
+ ASSERT_EQ(ProfileAssistant::kCompile,
+ CheckCompilationMethodPercentChange(kNumberOfMethodsInCurProfile,
+ kNumberOfMethodsInRefProfile));
+}
+
+TEST_F(ProfileAssistantTest, DoNotdviseCompilationClassPercentage) {
+ const uint16_t kNumberOfClassesInRefProfile = 6000;
+ const uint16_t kNumberOfClassesInCurProfile = 6110; // Threshold is 2%.
+ // We should not advise compilation.
+ ASSERT_EQ(ProfileAssistant::kSkipCompilation,
+ CheckCompilationClassPercentChange(kNumberOfClassesInCurProfile,
+ kNumberOfClassesInRefProfile));
+}
+
+TEST_F(ProfileAssistantTest, ShouldAdviseCompilationClassPercentage) {
+ const uint16_t kNumberOfClassesInRefProfile = 6000;
+ const uint16_t kNumberOfClassesInCurProfile = 6120; // Threshold is 2%.
+ // We should advise compilation.
+ ASSERT_EQ(ProfileAssistant::kCompile,
+ CheckCompilationClassPercentChange(kNumberOfClassesInCurProfile,
+ kNumberOfClassesInRefProfile));
+}
+
TEST_F(ProfileAssistantTest, FailProcessingBecauseOfProfiles) {
ScratchFile profile1;
ScratchFile profile2;