[compiler-rt] r229127 - tsan: don't initialize trace header in release mode
Dmitry Vyukov
dvyukov at google.com
Fri Feb 13 09:39:04 PST 2015
Author: dvyukov
Date: Fri Feb 13 11:39:03 2015
New Revision: 229127
URL: http://llvm.org/viewvc/llvm-project?rev=229127&view=rev
Log:
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
Modified:
compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc?rev=229127&r1=229126&r2=229127&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc Fri Feb 13 11:39:03 2015
@@ -68,7 +68,13 @@ static ThreadContextBase *CreateThreadCo
// 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);
}
More information about the llvm-commits
mailing list