liblog: android_log_isloggable failing apct

- periodic failures in apct, dropped second serial test
  in refresh_cache, trusting check_cache or global.
- The retry loop to see if is_loggable recovers of 1000
  was hiding subsequent tests, drop to 10 retries.
- On the whole, the average performance remains the same.

Bug: 25792367
Change-Id: I4110440ef46671d7a1c128689bde623808bed04f
This commit is contained in:
Mark Salyzyn 2016-04-14 15:31:56 -07:00
parent 1607ea64cb
commit efe8ecc1d9
2 changed files with 15 additions and 21 deletions

View File

@ -63,7 +63,6 @@ static int check_cache(struct cache *cache)
static void refresh_cache(struct cache *cache, const char *key)
{
uint32_t serial;
char buf[PROP_VALUE_MAX];
if (!cache->pinfo) {
@ -71,13 +70,8 @@ static void refresh_cache(struct cache *cache, const char *key)
if (!cache->pinfo) {
return;
}
cache->serial = -1;
}
serial = __system_property_serial(cache->pinfo);
if (serial == cache->serial) {
return;
}
cache->serial = serial;
cache->serial = __system_property_serial(cache->pinfo);
__system_property_read(cache->pinfo, 0, buf);
switch(buf[0]) {
case 't': case 'T':

View File

@ -1338,7 +1338,7 @@ TEST(liblog, is_loggable) {
fprintf(stderr, "\n");
}
EXPECT_FALSE(android_log_is_loggable);
for(size_t k = 1000; k; --k) {
for(size_t k = 10; k; --k) {
EXPECT_FALSE(__android_log_is_loggable(
levels[i].level, tag, levels[j].level));
}
@ -1347,7 +1347,7 @@ TEST(liblog, is_loggable) {
fprintf(stderr, "\n");
}
EXPECT_TRUE(android_log_is_loggable);
for(size_t k = 1000; k; --k) {
for(size_t k = 10; k; --k) {
EXPECT_TRUE(__android_log_is_loggable(
levels[i].level, tag, levels[j].level));
}
@ -1379,7 +1379,7 @@ TEST(liblog, is_loggable) {
fprintf(stderr, "\n");
}
EXPECT_FALSE(android_log_is_loggable);
for(size_t k = 1000; k; --k) {
for(size_t k = 10; k; --k) {
EXPECT_FALSE(__android_log_is_loggable(
levels[i].level, tag, ANDROID_LOG_DEBUG));
}
@ -1388,7 +1388,7 @@ TEST(liblog, is_loggable) {
fprintf(stderr, "\n");
}
EXPECT_TRUE(android_log_is_loggable);
for(size_t k = 1000; k; --k) {
for(size_t k = 10; k; --k) {
EXPECT_TRUE(__android_log_is_loggable(
levels[i].level, tag, ANDROID_LOG_DEBUG));
}
@ -1408,7 +1408,7 @@ TEST(liblog, is_loggable) {
fprintf(stderr, "\n");
}
EXPECT_FALSE(android_log_is_loggable);
for(size_t k = 1000; k; --k) {
for(size_t k = 10; k; --k) {
EXPECT_FALSE(__android_log_is_loggable(
levels[i].level, tag, ANDROID_LOG_DEBUG));
}
@ -1417,7 +1417,7 @@ TEST(liblog, is_loggable) {
fprintf(stderr, "\n");
}
EXPECT_TRUE(android_log_is_loggable);
for(size_t k = 1000; k; --k) {
for(size_t k = 10; k; --k) {
EXPECT_TRUE(__android_log_is_loggable(
levels[i].level, tag, ANDROID_LOG_DEBUG));
}
@ -1439,7 +1439,7 @@ TEST(liblog, is_loggable) {
fprintf(stderr, "\n");
}
EXPECT_FALSE(android_log_is_loggable);
for(size_t k = 1000; k; --k) {
for(size_t k = 10; k; --k) {
EXPECT_FALSE(__android_log_is_loggable(
levels[i].level, tag, ANDROID_LOG_DEBUG));
}
@ -1448,7 +1448,7 @@ TEST(liblog, is_loggable) {
fprintf(stderr, "\n");
}
EXPECT_TRUE(android_log_is_loggable);
for(size_t k = 1000; k; --k) {
for(size_t k = 10; k; --k) {
EXPECT_TRUE(__android_log_is_loggable(
levels[i].level, tag, ANDROID_LOG_DEBUG));
}
@ -1468,7 +1468,7 @@ TEST(liblog, is_loggable) {
fprintf(stderr, "\n");
}
EXPECT_FALSE(android_log_is_loggable);
for(size_t k = 1000; k; --k) {
for(size_t k = 10; k; --k) {
EXPECT_FALSE(__android_log_is_loggable(
levels[i].level, tag, ANDROID_LOG_DEBUG));
}
@ -1477,7 +1477,7 @@ TEST(liblog, is_loggable) {
fprintf(stderr, "\n");
}
EXPECT_TRUE(android_log_is_loggable);
for(size_t k = 1000; k; --k) {
for(size_t k = 10; k; --k) {
EXPECT_TRUE(__android_log_is_loggable(
levels[i].level, tag, ANDROID_LOG_DEBUG));
}
@ -1513,7 +1513,7 @@ TEST(liblog, is_loggable) {
fprintf(stderr, "\n");
}
EXPECT_FALSE(android_log_is_loggable);
for(size_t k = 1000; k; --k) {
for(size_t k = 10; k; --k) {
EXPECT_FALSE(__android_log_is_loggable(
levels[i].level, tag, ANDROID_LOG_DEBUG));
}
@ -1522,7 +1522,7 @@ TEST(liblog, is_loggable) {
fprintf(stderr, "\n");
}
EXPECT_TRUE(android_log_is_loggable);
for(size_t k = 1000; k; --k) {
for(size_t k = 10; k; --k) {
EXPECT_TRUE(__android_log_is_loggable(
levels[i].level, tag, ANDROID_LOG_DEBUG));
}
@ -1542,7 +1542,7 @@ TEST(liblog, is_loggable) {
fprintf(stderr, "\n");
}
EXPECT_FALSE(android_log_is_loggable);
for(size_t k = 1000; k; --k) {
for(size_t k = 10; k; --k) {
EXPECT_FALSE(__android_log_is_loggable(
levels[i].level, tag, ANDROID_LOG_DEBUG));
}
@ -1551,7 +1551,7 @@ TEST(liblog, is_loggable) {
fprintf(stderr, "\n");
}
EXPECT_TRUE(android_log_is_loggable);
for(size_t k = 1000; k; --k) {
for(size_t k = 10; k; --k) {
EXPECT_TRUE(__android_log_is_loggable(
levels[i].level, tag, ANDROID_LOG_DEBUG));
}