diff options
author | Mark Salyzyn | 2015-08-19 14:20:36 -0500 |
---|---|---|
committer | Mark Salyzyn | 2015-08-20 10:35:45 -0500 |
commit | b39ed0c9925356c74a6347630b04d875288d803b (patch) | |
tree | cf1d710ab48cfedcf67b444d3a8ac1b227755a64 /logd/LogBuffer.cpp | |
parent | e03d0322db8ed123254482d0b0905646b16ad71e (diff) | |
download | platform-system-core-b39ed0c9925356c74a6347630b04d875288d803b.tar.gz platform-system-core-b39ed0c9925356c74a6347630b04d875288d803b.tar.xz platform-system-core-b39ed0c9925356c74a6347630b04d875288d803b.zip |
logd: prune 10% or 256 entries max
Bug: 22351810
Bug: 23327476
Change-Id: I902ba6b431d8b7cee2d65ee2f76e9f7c4f30b152
Diffstat (limited to 'logd/LogBuffer.cpp')
-rw-r--r-- | logd/LogBuffer.cpp | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/logd/LogBuffer.cpp b/logd/LogBuffer.cpp index b9e8973ac..85f770a95 100644 --- a/logd/LogBuffer.cpp +++ b/logd/LogBuffer.cpp | |||
@@ -217,27 +217,23 @@ int LogBuffer::log(log_id_t log_id, log_time realtime, | |||
217 | return len; | 217 | return len; |
218 | } | 218 | } |
219 | 219 | ||
220 | // If we're using more than 256K of memory for log entries, prune | 220 | // Prune at most 10% of the log entries or 256, whichever is less. |
221 | // at least 10% of the log entries. For sizes above 1M, prune at | ||
222 | // least 1% of the log entries. | ||
223 | // | 221 | // |
224 | // mLogElementsLock must be held when this function is called. | 222 | // mLogElementsLock must be held when this function is called. |
225 | void LogBuffer::maybePrune(log_id_t id) { | 223 | void LogBuffer::maybePrune(log_id_t id) { |
226 | size_t sizes = stats.sizes(id); | 224 | size_t sizes = stats.sizes(id); |
227 | unsigned long maxSize = log_buffer_size(id); | 225 | unsigned long maxSize = log_buffer_size(id); |
228 | if (sizes > maxSize) { | 226 | if (sizes > maxSize) { |
229 | size_t sizeOver, minElements, elements = stats.elements(id); | 227 | size_t sizeOver = sizes - ((maxSize * 9) / 10); |
230 | if (maxSize > (4 * LOG_BUFFER_SIZE)) { | 228 | size_t elements = stats.elements(id); |
231 | sizeOver = sizes - ((maxSize * 99) / 100); | 229 | size_t minElements = elements / 10; |
232 | minElements = elements / 100; | ||
233 | } else { | ||
234 | sizeOver = sizes - ((maxSize * 9) / 10); | ||
235 | minElements = elements / 10; | ||
236 | } | ||
237 | unsigned long pruneRows = elements * sizeOver / sizes; | 230 | unsigned long pruneRows = elements * sizeOver / sizes; |
238 | if (pruneRows <= minElements) { | 231 | if (pruneRows <= minElements) { |
239 | pruneRows = minElements; | 232 | pruneRows = minElements; |
240 | } | 233 | } |
234 | if (pruneRows > 256) { | ||
235 | pruneRows = 256; | ||
236 | } | ||
241 | prune(id, pruneRows); | 237 | prune(id, pruneRows); |
242 | } | 238 | } |
243 | } | 239 | } |