summaryrefslogtreecommitdiffstats
path: root/logd/LogBuffer.cpp
diff options
context:
space:
mode:
authorMark Salyzyn <salyzyn@google.com>2015-08-10 10:23:56 -0700
committerMark Salyzyn <salyzyn@google.com>2015-08-20 11:28:53 -0700
commit8894c395bfcb80f0bedea8fcc0e8ef51e51dc883 (patch)
treed403f170d2bbcf7fcd1d66354eb2645accd6944e /logd/LogBuffer.cpp
parent946533648c49f2700b6e0f73383699597649ee60 (diff)
downloadsystem_core-8894c395bfcb80f0bedea8fcc0e8ef51e51dc883.zip
system_core-8894c395bfcb80f0bedea8fcc0e8ef51e51dc883.tar.gz
system_core-8894c395bfcb80f0bedea8fcc0e8ef51e51dc883.tar.bz2
logd: sizes > 1M prune in smaller batches
(cherry pick from commit 62ab0fd4efeed313adf2fdf84167d754620c0ad1) Switch to 1% batch sizes from 10% when individual buffer size > 1M Bug: 22351810 Change-Id: Ifee570a54643ceb0ba767e1787e937f70cc90b72
Diffstat (limited to 'logd/LogBuffer.cpp')
-rw-r--r--logd/LogBuffer.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/logd/LogBuffer.cpp b/logd/LogBuffer.cpp
index 0f5071b..b9e8973 100644
--- a/logd/LogBuffer.cpp
+++ b/logd/LogBuffer.cpp
@@ -218,18 +218,25 @@ int LogBuffer::log(log_id_t log_id, log_time realtime,
}
// If we're using more than 256K of memory for log entries, prune
-// at least 10% of the log entries.
+// at least 10% of the log entries. For sizes above 1M, prune at
+// least 1% of the log entries.
//
// mLogElementsLock must be held when this function is called.
void LogBuffer::maybePrune(log_id_t id) {
size_t sizes = stats.sizes(id);
- if (sizes > log_buffer_size(id)) {
- size_t sizeOver90Percent = sizes - ((log_buffer_size(id) * 9) / 10);
- size_t elements = stats.elements(id);
- unsigned long pruneRows = elements * sizeOver90Percent / sizes;
- elements /= 10;
- if (pruneRows <= elements) {
- pruneRows = elements;
+ unsigned long maxSize = log_buffer_size(id);
+ if (sizes > maxSize) {
+ size_t sizeOver, minElements, elements = stats.elements(id);
+ if (maxSize > (4 * LOG_BUFFER_SIZE)) {
+ sizeOver = sizes - ((maxSize * 99) / 100);
+ minElements = elements / 100;
+ } else {
+ sizeOver = sizes - ((maxSize * 9) / 10);
+ minElements = elements / 10;
+ }
+ unsigned long pruneRows = elements * sizeOver / sizes;
+ if (pruneRows <= minElements) {
+ pruneRows = minElements;
}
prune(id, pruneRows);
}