Bug 915244 - Tracelogging: Enable logging the gc background thread, r=till

This commit is contained in:
Hannes Verschore 2013-09-17 10:27:58 +02:00
parent 3a02cd08ea
commit 1aadcb4372
3 changed files with 41 additions and 16 deletions

View File

@ -76,6 +76,10 @@ const char* const TraceLogging::typeName[] = {
"0,G", // stop major GC
"1,g", // start minor GC
"0,g", // stop minor GC
"1,gS", // start GC sweeping
"0,gS", // stop GC sweeping
"1,gA", // start GC allocating
"0,gA", // stop GC allocating
"1,ps", // start script parsing
"0,ps", // stop script parsing
"1,pl", // start lazy parsing
@ -86,13 +90,12 @@ const char* const TraceLogging::typeName[] = {
"e,b", // engine baseline
"e,o" // engine ionmonkey
};
TraceLogging* TraceLogging::loggers[] = {NULL, NULL};
TraceLogging* TraceLogging::loggers[] = {NULL, NULL, NULL};
bool TraceLogging::atexitSet = false;
uint64_t TraceLogging::startupTime = 0;
TraceLogging::TraceLogging(Logger id)
: loggingTime(0),
nextTextId(1),
: nextTextId(1),
entries(NULL),
curEntry(0),
numEntries(1000000),
@ -105,16 +108,16 @@ TraceLogging::TraceLogging(Logger id)
TraceLogging::~TraceLogging()
{
if (out) {
fclose(out);
out = NULL;
}
if (entries) {
flush();
free(entries);
entries = NULL;
}
if (out) {
fclose(out);
out = NULL;
}
}
void
@ -163,16 +166,11 @@ TraceLogging::log(Type type, const char* text /* = NULL */, unsigned int number
}
}
entries[curEntry++] = Entry(now - loggingTime, text_, textId, number, type);
entries[curEntry++] = Entry(now, text_, textId, number, type);
// Increase length when not enough place in the array
if (curEntry >= numEntries)
grow();
// Save the time spend logging the information in order to discard this
// time from the logged time. Especially needed when increasing the array
// or flushing the information.
loggingTime += rdtsc() - startupTime - now;
}
void
@ -205,6 +203,9 @@ TraceLogging::flush()
case ION_BACKGROUND_COMPILER:
out = fopen(TRACE_LOG_DIR "tracelogging-compile.log", "w");
break;
case GC_BACKGROUND:
out = fopen(TRACE_LOG_DIR "tracelogging-gc.log", "w");
break;
default:
MOZ_ASSUME_UNREACHABLE("Bad trigger");
return;

View File

@ -35,6 +35,10 @@ class TraceLogging
GC_STOP,
MINOR_GC_START,
MINOR_GC_STOP,
GC_SWEEPING_START,
GC_SWEEPING_STOP,
GC_ALLOCATING_START,
GC_ALLOCATING_STOP,
PARSER_COMPILE_SCRIPT_START,
PARSER_COMPILE_SCRIPT_STOP,
PARSER_COMPILE_LAZY_START,
@ -49,6 +53,7 @@ class TraceLogging
enum Logger {
DEFAULT,
ION_BACKGROUND_COMPILER,
GC_BACKGROUND,
LAST_LOGGER
};
@ -80,7 +85,6 @@ class TraceLogging
PointerHasher<const char *, 3>,
SystemAllocPolicy> TextHashMap;
uint64_t loggingTime;
TextHashMap textMap;
uint32_t nextTextId;
Entry *entries;

View File

@ -2281,6 +2281,10 @@ GCHelperThread::threadLoop()
{
AutoLockGC lock(rt);
#if JS_TRACE_LOGGING
TraceLogging *logger = TraceLogging::getLogger(TraceLogging::GC_BACKGROUND);
#endif
/*
* Even on the first iteration the state can be SHUTDOWN or SWEEPING if
* the stop request or the GC and the corresponding startBackgroundSweep call
@ -2294,12 +2298,21 @@ GCHelperThread::threadLoop()
PR_WaitCondVar(wakeup, PR_INTERVAL_NO_TIMEOUT);
break;
case SWEEPING:
#if JS_TRACE_LOGGING
logger->log(TraceLogging::GC_SWEEPING_START);
#endif
doSweep();
if (state == SWEEPING)
state = IDLE;
PR_NotifyAllCondVar(done);
#if JS_TRACE_LOGGING
logger->log(TraceLogging::GC_SWEEPING_STOP);
#endif
break;
case ALLOCATING:
#if JS_TRACE_LOGGING
logger->log(TraceLogging::GC_ALLOCATING_START);
#endif
do {
Chunk *chunk;
{
@ -2308,14 +2321,21 @@ GCHelperThread::threadLoop()
}
/* OOM stops the background allocation. */
if (!chunk)
if (!chunk) {
#if JS_TRACE_LOGGING
logger->log(TraceLogging::GC_ALLOCATING_STOP);
#endif
break;
}
JS_ASSERT(chunk->info.numArenasFreeCommitted == ArenasPerChunk);
rt->gcNumArenasFreeCommitted += ArenasPerChunk;
rt->gcChunkPool.put(chunk);
} while (state == ALLOCATING && rt->gcChunkPool.wantBackgroundAllocation(rt));
if (state == ALLOCATING)
state = IDLE;
#if JS_TRACE_LOGGING
logger->log(TraceLogging::GC_ALLOCATING_STOP);
#endif
break;
case CANCEL_ALLOCATION:
state = IDLE;