Merge "logd: worst uid record watermark"
This commit is contained in:
commit
07ee12aafc
2 changed files with 23 additions and 1 deletions
|
|
@ -240,7 +240,12 @@ void LogBuffer::maybePrune(log_id_t id) {
|
||||||
|
|
||||||
LogBufferElementCollection::iterator LogBuffer::erase(LogBufferElementCollection::iterator it) {
|
LogBufferElementCollection::iterator LogBuffer::erase(LogBufferElementCollection::iterator it) {
|
||||||
LogBufferElement *e = *it;
|
LogBufferElement *e = *it;
|
||||||
|
log_id_t id = e->getLogId();
|
||||||
|
LogBufferIteratorMap::iterator f = mLastWorstUid[id].find(e->getUid());
|
||||||
|
|
||||||
|
if ((f != mLastWorstUid[id].end()) && (it == f->second)) {
|
||||||
|
mLastWorstUid[id].erase(f);
|
||||||
|
}
|
||||||
it = mLogElements.erase(it);
|
it = mLogElements.erase(it);
|
||||||
stats.subtract(e);
|
stats.subtract(e);
|
||||||
delete e;
|
delete e;
|
||||||
|
|
@ -399,8 +404,17 @@ void LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) {
|
||||||
|
|
||||||
bool kick = false;
|
bool kick = false;
|
||||||
bool leading = true;
|
bool leading = true;
|
||||||
|
it = mLogElements.begin();
|
||||||
|
if (worst != (uid_t) -1) {
|
||||||
|
LogBufferIteratorMap::iterator f = mLastWorstUid[id].find(worst);
|
||||||
|
if ((f != mLastWorstUid[id].end())
|
||||||
|
&& (f->second != mLogElements.end())) {
|
||||||
|
leading = false;
|
||||||
|
it = f->second;
|
||||||
|
}
|
||||||
|
}
|
||||||
LogBufferElementLast last;
|
LogBufferElementLast last;
|
||||||
for(it = mLogElements.begin(); it != mLogElements.end();) {
|
while (it != mLogElements.end()) {
|
||||||
LogBufferElement *e = *it;
|
LogBufferElement *e = *it;
|
||||||
|
|
||||||
if (oldest && (oldest->mStart <= e->getSequence())) {
|
if (oldest && (oldest->mStart <= e->getSequence())) {
|
||||||
|
|
@ -450,8 +464,10 @@ void LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// unmerged drop message
|
||||||
if (dropped) {
|
if (dropped) {
|
||||||
last.add(e);
|
last.add(e);
|
||||||
|
mLastWorstUid[id][e->getUid()] = it;
|
||||||
++it;
|
++it;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -496,6 +512,7 @@ void LogBuffer::prune(log_id_t id, unsigned long pruneRows, uid_t caller_uid) {
|
||||||
delete e;
|
delete e;
|
||||||
} else {
|
} else {
|
||||||
last.add(e);
|
last.add(e);
|
||||||
|
mLastWorstUid[id][e->getUid()] = it;
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,11 @@ class LogBuffer {
|
||||||
LogStatistics stats;
|
LogStatistics stats;
|
||||||
|
|
||||||
PruneList mPrune;
|
PruneList mPrune;
|
||||||
|
// watermark of any worst/chatty uid processing
|
||||||
|
typedef std::unordered_map<uid_t,
|
||||||
|
LogBufferElementCollection::iterator>
|
||||||
|
LogBufferIteratorMap;
|
||||||
|
LogBufferIteratorMap mLastWorstUid[LOG_ID_MAX];
|
||||||
|
|
||||||
unsigned long mMaxSize[LOG_ID_MAX];
|
unsigned long mMaxSize[LOG_ID_MAX];
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue