tsan: don't initialize trace header in release mode

We are going to use only a small part of the trace with the default
value of history_size. However, the constructor writes to the whole trace.
It writes mostly zeros, so freshly mmaped memory will do.
The only non-zero field if mutex type used for debugging.

Reduces per-goroutine overhead by 8K.

https://code.google.com/p/thread-sanitizer/issues/detail?id=89

llvm-svn: 229127
This commit is contained in:
Dmitry Vyukov 2015-02-13 17:39:03 +00:00
parent ebfe815f5c
commit 8a9d23bf53
1 changed files with 6 additions and 0 deletions

View File

@ -68,7 +68,13 @@ static ThreadContextBase *CreateThreadContext(u32 tid) {
// Map thread trace when context is created.
MapThreadTrace(GetThreadTrace(tid), TraceSize() * sizeof(Event));
MapThreadTrace(GetThreadTraceHeader(tid), sizeof(Trace));
#if SANITIZER_DEBUG
// We are going to use only a small part of the trace with the default
// value of history_size. However, the constructor writes to the whole trace.
// It writes mostly zeros, so freshly mmaped memory will do.
// The only non-zero field if mutex type used for debugging.
new(ThreadTrace(tid)) Trace();
#endif
void *mem = internal_alloc(MBlockThreadContex, sizeof(ThreadContext));
return new(mem) ThreadContext(tid);
}