diff options
author | 2022-08-11 12:30:22 +0000 | |
---|---|---|
committer | 2022-08-12 17:08:54 +0000 | |
commit | 43f27b7897c876bdb965e9acca5c7d18e031efd7 (patch) | |
tree | ecb2a2236413656fdd05caaaac1d6bbb6fd68cb2 | |
parent | 7cc22bb96e4e05cf63661eed7fd3dda5304bdacc (diff) |
Don't apply backoff time if the last compilation succeeded.
This change is supposed to be a no-op change, but it makes the logic
more straghtforward and therefore avoids potential pitfalls that can be
introduced by future changes.
Bug: 241512616
Change-Id: I4623b1f2cc1169d6405d850564d33a2f8c697524
Test: Presubmit
-rw-r--r-- | odrefresh/odr_compilation_log.cc | 6 | ||||
-rw-r--r-- | odrefresh/odr_compilation_log_test.cc | 8 |
2 files changed, 10 insertions, 4 deletions
diff --git a/odrefresh/odr_compilation_log.cc b/odrefresh/odr_compilation_log.cc index 9c50817b19..0c8dda8805 100644 --- a/odrefresh/odr_compilation_log.cc +++ b/odrefresh/odr_compilation_log.cc @@ -185,6 +185,12 @@ bool OdrCompilationLog::ShouldAttemptCompile(OdrMetrics::Trigger trigger, time_t return true; } + // The backoff time is for avoiding too many failed attempts. It should not be applied if the last + // compilation was successful. + if (entries_.back().exit_code == ExitCode::kCompilationSuccess) { + return true; + } + if (trigger == OdrMetrics::Trigger::kApexVersionMismatch || trigger == OdrMetrics::Trigger::kDexFilesChanged) { // Things have changed since the last run. diff --git a/odrefresh/odr_compilation_log_test.cc b/odrefresh/odr_compilation_log_test.cc index 46cea798ba..f28d849575 100644 --- a/odrefresh/odr_compilation_log_test.cc +++ b/odrefresh/odr_compilation_log_test.cc @@ -109,7 +109,7 @@ TEST(OdrCompilationLog, ShouldAttemptCompile) { /*apex_version=*/1, /*last_update_millis=*/762, OdrMetrics::Trigger::kApexVersionMismatch, - ExitCode::kCompilationSuccess); + ExitCode::kCompilationFailed); ASSERT_TRUE(ocl.ShouldAttemptCompile(OdrMetrics::Trigger::kApexVersionMismatch)); ASSERT_TRUE(ocl.ShouldAttemptCompile(OdrMetrics::Trigger::kDexFilesChanged)); ASSERT_FALSE(ocl.ShouldAttemptCompile(OdrMetrics::Trigger::kUnknown)); @@ -180,8 +180,8 @@ TEST(OdrCompilationLog, BackOffHappyHistory) { OdrMetrics::Trigger::kApexVersionMismatch, start_time, ExitCode::kCompilationSuccess); - ASSERT_FALSE(ocl.ShouldAttemptCompile(OdrMetrics::Trigger::kUnknown, start_time)); - ASSERT_FALSE( + ASSERT_TRUE(ocl.ShouldAttemptCompile(OdrMetrics::Trigger::kUnknown, start_time)); + ASSERT_TRUE( ocl.ShouldAttemptCompile(OdrMetrics::Trigger::kUnknown, start_time + kSecondsPerDay / 4)); ASSERT_TRUE( ocl.ShouldAttemptCompile(OdrMetrics::Trigger::kUnknown, start_time + kSecondsPerDay / 2)); @@ -382,7 +382,7 @@ TEST_F(OdrCompilationLogTest, NewLogVersionTriggersCompilation) { kLastUpdateMillis, OdrMetrics::Trigger::kApexVersionMismatch, start_time, - ExitCode::kCompilationSuccess); + ExitCode::kCompilationFailed); ASSERT_FALSE(ocl.ShouldAttemptCompile(OdrMetrics::Trigger::kUnknown, start_time)); } } |