mirror of
https://github.com/glest/glest-source.git
synced 2025-08-29 19:00:07 +02:00
- trying to tweak threaded logger performance when log entries are in the hundreds of thousands
This commit is contained in:
@@ -207,15 +207,15 @@ void LogFileThread::addLogEntry(SystemFlags::DebugType type, string logEntry) {
|
|||||||
entry.entryDateTime = time(NULL);
|
entry.entryDateTime = time(NULL);
|
||||||
logList.push_back(entry);
|
logList.push_back(entry);
|
||||||
|
|
||||||
if(logList.size() >= 750000) {
|
//if(logList.size() >= 750000) {
|
||||||
saveToDisk(false,true);
|
// saveToDisk(false,true);
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LogFileThread::checkSaveCurrentLogBufferToDisk() {
|
bool LogFileThread::checkSaveCurrentLogBufferToDisk() {
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
if(difftime(time(NULL),lastSaveToDisk) >= 10 ||
|
if(difftime(time(NULL),lastSaveToDisk) >= 10 ||
|
||||||
LogFileThread::getLogEntryBufferCount() >= 500000) {
|
LogFileThread::getLogEntryBufferCount() >= 2000000) {
|
||||||
lastSaveToDisk = time(NULL);
|
lastSaveToDisk = time(NULL);
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
@@ -275,20 +275,20 @@ void LogFileThread::saveToDisk(bool forceSaveAll,bool logListAlreadyLocked) {
|
|||||||
|
|
||||||
std::size_t logCount = logList.size();
|
std::size_t logCount = logList.size();
|
||||||
if(logCount > 0) {
|
if(logCount > 0) {
|
||||||
//vector<LogFileEntry> tempLogList = logList;
|
vector<LogFileEntry> tempLogList = logList;
|
||||||
//safeMutex.ReleaseLock(true);
|
safeMutex.ReleaseLock(true);
|
||||||
|
|
||||||
//logCount = tempLogList.size();
|
logCount = tempLogList.size();
|
||||||
if(forceSaveAll == false) {
|
//if(forceSaveAll == false) {
|
||||||
logCount = min(logCount,(std::size_t)1000000);
|
// logCount = min(logCount,(std::size_t)2000000);
|
||||||
}
|
//}
|
||||||
|
|
||||||
for(int i = 0; i < logCount; ++i) {
|
for(int i = 0; i < logCount; ++i) {
|
||||||
LogFileEntry &entry = logList[i];
|
LogFileEntry &entry = tempLogList[i];
|
||||||
SystemFlags::logDebugEntry(entry.type, entry.entry, entry.entryDateTime);
|
SystemFlags::logDebugEntry(entry.type, entry.entry, entry.entryDateTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
//safeMutex.Lock();
|
safeMutex.Lock();
|
||||||
logList.erase(logList.begin(),logList.begin() + logCount);
|
logList.erase(logList.begin(),logList.begin() + logCount);
|
||||||
safeMutex.ReleaseLock();
|
safeMutex.ReleaseLock();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user