am 2c1b8f9e: Merge changes Ib0530b9d,I981d9fa6,Icc60dd06,I902ba6b4
* commit '2c1b8f9e200abdbc42addd33829616393067b96a': logd: log buffer switch to std::list logd: white and black switch to std::list logd: logtimes switch to std::list logd: prune 10% or 256 entries max
This commit is contained in:
commit
44a7da74bd
6 changed files with 29 additions and 36 deletions
|
|
@ -72,7 +72,7 @@ void FlushCommand::runSocketCommand(SocketClient *client) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
entry = new LogTimeEntry(mReader, client, mNonBlock, mTail, mLogMask, mPid, mStart);
|
entry = new LogTimeEntry(mReader, client, mNonBlock, mTail, mLogMask, mPid, mStart);
|
||||||
times.push_back(entry);
|
times.push_front(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
client->incRef();
|
client->incRef();
|
||||||
|
|
|
||||||
|
|
@ -217,27 +217,23 @@ int LogBuffer::log(log_id_t log_id, log_time realtime,
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we're using more than 256K of memory for log entries, prune
|
// Prune at most 10% of the log entries or 256, whichever is less.
|
||||||
// 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.
|
// mLogElementsLock must be held when this function is called.
|
||||||
void LogBuffer::maybePrune(log_id_t id) {
|
void LogBuffer::maybePrune(log_id_t id) {
|
||||||
size_t sizes = stats.sizes(id);
|
size_t sizes = stats.sizes(id);
|
||||||
unsigned long maxSize = log_buffer_size(id);
|
unsigned long maxSize = log_buffer_size(id);
|
||||||
if (sizes > maxSize) {
|
if (sizes > maxSize) {
|
||||||
size_t sizeOver, minElements, elements = stats.elements(id);
|
size_t sizeOver = sizes - ((maxSize * 9) / 10);
|
||||||
if (maxSize > (4 * LOG_BUFFER_SIZE)) {
|
size_t elements = stats.elements(id);
|
||||||
sizeOver = sizes - ((maxSize * 99) / 100);
|
size_t minElements = elements / 10;
|
||||||
minElements = elements / 100;
|
|
||||||
} else {
|
|
||||||
sizeOver = sizes - ((maxSize * 9) / 10);
|
|
||||||
minElements = elements / 10;
|
|
||||||
}
|
|
||||||
unsigned long pruneRows = elements * sizeOver / sizes;
|
unsigned long pruneRows = elements * sizeOver / sizes;
|
||||||
if (pruneRows <= minElements) {
|
if (pruneRows <= minElements) {
|
||||||
pruneRows = minElements;
|
pruneRows = minElements;
|
||||||
}
|
}
|
||||||
|
if (pruneRows > 256) {
|
||||||
|
pruneRows = 256;
|
||||||
|
}
|
||||||
prune(id, pruneRows);
|
prune(id, pruneRows);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,10 @@
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <list>
|
||||||
|
|
||||||
#include <log/log.h>
|
#include <log/log.h>
|
||||||
#include <sysutils/SocketClient.h>
|
#include <sysutils/SocketClient.h>
|
||||||
#include <utils/List.h>
|
|
||||||
|
|
||||||
#include <private/android_filesystem_config.h>
|
#include <private/android_filesystem_config.h>
|
||||||
|
|
||||||
|
|
@ -30,7 +31,7 @@
|
||||||
#include "LogStatistics.h"
|
#include "LogStatistics.h"
|
||||||
#include "LogWhiteBlackList.h"
|
#include "LogWhiteBlackList.h"
|
||||||
|
|
||||||
typedef android::List<LogBufferElement *> LogBufferElementCollection;
|
typedef std::list<LogBufferElement *> LogBufferElementCollection;
|
||||||
|
|
||||||
class LogBuffer {
|
class LogBuffer {
|
||||||
LogBufferElementCollection mLogElements;
|
LogBufferElementCollection mLogElements;
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,10 @@
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <list>
|
||||||
|
|
||||||
#include <sysutils/SocketClient.h>
|
#include <sysutils/SocketClient.h>
|
||||||
#include <utils/List.h>
|
|
||||||
#include <log/log.h>
|
#include <log/log.h>
|
||||||
|
|
||||||
class LogReader;
|
class LogReader;
|
||||||
|
|
@ -107,6 +109,6 @@ public:
|
||||||
static int FilterSecondPass(const LogBufferElement *element, void *me);
|
static int FilterSecondPass(const LogBufferElement *element, void *me);
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef android::List<LogTimeEntry *> LastLogTimes;
|
typedef std::list<LogTimeEntry *> LastLogTimes;
|
||||||
|
|
||||||
#endif
|
#endif // _LOGD_LOG_TIMES_H__
|
||||||
|
|
|
||||||
|
|
@ -50,18 +50,14 @@ void Prune::format(char **strp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
PruneList::PruneList() : mWorstUidEnabled(true) {
|
PruneList::PruneList() : mWorstUidEnabled(true) {
|
||||||
mNaughty.clear();
|
|
||||||
mNice.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PruneList::~PruneList() {
|
PruneList::~PruneList() {
|
||||||
PruneCollection::iterator it;
|
PruneCollection::iterator it;
|
||||||
for (it = mNice.begin(); it != mNice.end();) {
|
for (it = mNice.begin(); it != mNice.end();) {
|
||||||
delete (*it);
|
|
||||||
it = mNice.erase(it);
|
it = mNice.erase(it);
|
||||||
}
|
}
|
||||||
for (it = mNaughty.begin(); it != mNaughty.end();) {
|
for (it = mNaughty.begin(); it != mNaughty.end();) {
|
||||||
delete (*it);
|
|
||||||
it = mNaughty.erase(it);
|
it = mNaughty.erase(it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -70,11 +66,9 @@ int PruneList::init(char *str) {
|
||||||
mWorstUidEnabled = true;
|
mWorstUidEnabled = true;
|
||||||
PruneCollection::iterator it;
|
PruneCollection::iterator it;
|
||||||
for (it = mNice.begin(); it != mNice.end();) {
|
for (it = mNice.begin(); it != mNice.end();) {
|
||||||
delete (*it);
|
|
||||||
it = mNice.erase(it);
|
it = mNice.erase(it);
|
||||||
}
|
}
|
||||||
for (it = mNaughty.begin(); it != mNaughty.end();) {
|
for (it = mNaughty.begin(); it != mNaughty.end();) {
|
||||||
delete (*it);
|
|
||||||
it = mNaughty.erase(it);
|
it = mNaughty.erase(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -142,28 +136,28 @@ int PruneList::init(char *str) {
|
||||||
// insert sequentially into list
|
// insert sequentially into list
|
||||||
PruneCollection::iterator it = list->begin();
|
PruneCollection::iterator it = list->begin();
|
||||||
while (it != list->end()) {
|
while (it != list->end()) {
|
||||||
Prune *p = *it;
|
Prune &p = *it;
|
||||||
int m = uid - p->mUid;
|
int m = uid - p.mUid;
|
||||||
if (m == 0) {
|
if (m == 0) {
|
||||||
if (p->mPid == p->pid_all) {
|
if (p.mPid == p.pid_all) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ((pid == p->pid_all) && (p->mPid != p->pid_all)) {
|
if ((pid == p.pid_all) && (p.mPid != p.pid_all)) {
|
||||||
it = list->erase(it);
|
it = list->erase(it);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
m = pid - p->mPid;
|
m = pid - p.mPid;
|
||||||
}
|
}
|
||||||
if (m <= 0) {
|
if (m <= 0) {
|
||||||
if (m < 0) {
|
if (m < 0) {
|
||||||
list->insert(it, new Prune(uid,pid));
|
list->insert(it, Prune(uid,pid));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
if (it == list->end()) {
|
if (it == list->end()) {
|
||||||
list->push_back(new Prune(uid,pid));
|
list->push_back(Prune(uid,pid));
|
||||||
}
|
}
|
||||||
if (!*str) {
|
if (!*str) {
|
||||||
break;
|
break;
|
||||||
|
|
@ -193,7 +187,7 @@ void PruneList::format(char **strp) {
|
||||||
|
|
||||||
for (it = mNice.begin(); it != mNice.end(); ++it) {
|
for (it = mNice.begin(); it != mNice.end(); ++it) {
|
||||||
char *a = NULL;
|
char *a = NULL;
|
||||||
(*it)->format(&a);
|
(*it).format(&a);
|
||||||
|
|
||||||
string.appendFormat(fmt, a);
|
string.appendFormat(fmt, a);
|
||||||
fmt = nice_format;
|
fmt = nice_format;
|
||||||
|
|
@ -205,7 +199,7 @@ void PruneList::format(char **strp) {
|
||||||
fmt = naughty_format + (*fmt != ' ');
|
fmt = naughty_format + (*fmt != ' ');
|
||||||
for (it = mNaughty.begin(); it != mNaughty.end(); ++it) {
|
for (it = mNaughty.begin(); it != mNaughty.end(); ++it) {
|
||||||
char *a = NULL;
|
char *a = NULL;
|
||||||
(*it)->format(&a);
|
(*it).format(&a);
|
||||||
|
|
||||||
string.appendFormat(fmt, a);
|
string.appendFormat(fmt, a);
|
||||||
fmt = naughty_format;
|
fmt = naughty_format;
|
||||||
|
|
@ -223,7 +217,7 @@ void PruneList::format(char **strp) {
|
||||||
bool PruneList::naughty(LogBufferElement *element) {
|
bool PruneList::naughty(LogBufferElement *element) {
|
||||||
PruneCollection::iterator it;
|
PruneCollection::iterator it;
|
||||||
for (it = mNaughty.begin(); it != mNaughty.end(); ++it) {
|
for (it = mNaughty.begin(); it != mNaughty.end(); ++it) {
|
||||||
if (!(*it)->cmp(element)) {
|
if (!(*it).cmp(element)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -233,7 +227,7 @@ bool PruneList::naughty(LogBufferElement *element) {
|
||||||
bool PruneList::nice(LogBufferElement *element) {
|
bool PruneList::nice(LogBufferElement *element) {
|
||||||
PruneCollection::iterator it;
|
PruneCollection::iterator it;
|
||||||
for (it = mNice.begin(); it != mNice.end(); ++it) {
|
for (it = mNice.begin(); it != mNice.end(); ++it) {
|
||||||
if (!(*it)->cmp(element)) {
|
if (!(*it).cmp(element)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <utils/List.h>
|
#include <list>
|
||||||
|
|
||||||
#include <LogBufferElement.h>
|
#include <LogBufferElement.h>
|
||||||
|
|
||||||
|
|
@ -47,7 +47,7 @@ public:
|
||||||
void format(char **strp);
|
void format(char **strp);
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef android::List<Prune *> PruneCollection;
|
typedef std::list<Prune> PruneCollection;
|
||||||
|
|
||||||
class PruneList {
|
class PruneList {
|
||||||
PruneCollection mNaughty;
|
PruneCollection mNaughty;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue