summaryrefslogtreecommitdiff
path: root/logd/SerializedLogChunkTest.cpp
diff options
context:
space:
mode:
authorTom Cherry <tomcherry@google.com>2020-07-16 20:46:14 -0700
committerTom Cherry <tomcherry@google.com>2020-07-16 20:46:14 -0700
commit59caa7a04577579a899efdebff3fdb1377737138 (patch)
tree78e7c122bab9858d9b629353bdad368535086b01 /logd/SerializedLogChunkTest.cpp
parentb371af9e0fcd1d28dfb72541bbc4a57c762601f0 (diff)
logd: always compress SerializedLogChunk in FinishWriting()
When calculating the space used for pruning, if a log chunk is compressed, that size is used otherwise the uncompressed size is used. This is intended to reach a steady state where 1/4 of the log buffer is the uncompressed log chunk that is being written to and the other 3/4 of the log buffer is compressed logs. If we wait until there are no readers referencing the log chunk before compressing it, we end up with 2 uncompressed logs (the one that was just filled, that readers are still referencing, and the new one that was allocated to fit the most recent log), which take up 1/2 of the log buffer's allotted size and will thus cause prune to delete more compressed logs than it should. Instead, we should always compress the log chunks in FinishWriting() such that the compressed size will always be used for log chunks other than the one that is not actively written to. Decompressed logs due to readers are ephemeral by their nature and thus don't add to the log buffer size for pruning. Test: observe that log buffers can be filled in the presence of a reader. Change-Id: Ie21ccff032e41c4a0e51710cc435c5ab316563cb
Diffstat (limited to 'logd/SerializedLogChunkTest.cpp')
-rw-r--r--logd/SerializedLogChunkTest.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/logd/SerializedLogChunkTest.cpp b/logd/SerializedLogChunkTest.cpp
index 2b478a3fb..f10b9c673 100644
--- a/logd/SerializedLogChunkTest.cpp
+++ b/logd/SerializedLogChunkTest.cpp
@@ -113,8 +113,7 @@ TEST(SerializedLogChunk, three_logs) {
TEST(SerializedLogChunk, catch_DecCompressedRef_CHECK) {
size_t chunk_size = 10 * 4096;
auto chunk = SerializedLogChunk{chunk_size};
- EXPECT_DEATH({ chunk.DecReaderRefCount(true); }, "");
- EXPECT_DEATH({ chunk.DecReaderRefCount(false); }, "");
+ EXPECT_DEATH({ chunk.DecReaderRefCount(); }, "");
}
// Check that the CHECK() in ClearUidLogs() if the ref count is greater than 0 is caught.
@@ -123,7 +122,7 @@ TEST(SerializedLogChunk, catch_ClearUidLogs_CHECK) {
auto chunk = SerializedLogChunk{chunk_size};
chunk.IncReaderRefCount();
EXPECT_DEATH({ chunk.ClearUidLogs(1000, LOG_ID_MAIN, nullptr); }, "");
- chunk.DecReaderRefCount(false);
+ chunk.DecReaderRefCount();
}
class UidClearTest : public testing::TestWithParam<bool> {
@@ -144,7 +143,7 @@ class UidClearTest : public testing::TestWithParam<bool> {
check(chunk_);
if (finish_writing) {
- chunk_.DecReaderRefCount(false);
+ chunk_.DecReaderRefCount();
}
}