[compiler-rt] r229112 - tsan: remove stats from ThreadState ifndef TSAN_COLLECT_STATS

Dmitry Vyukov dvyukov at google.com
Fri Feb 13 07:25:47 PST 2015


Author: dvyukov
Date: Fri Feb 13 09:25:47 2015
New Revision: 229112

URL: http://llvm.org/viewvc/llvm-project?rev=229112&view=rev
Log:
tsan: remove stats from ThreadState ifndef TSAN_COLLECT_STATS

Issue 89: Uses a lot of memory for each goroutine
https://code.google.com/p/thread-sanitizer/issues/detail?id=89


Modified:
    compiler-rt/trunk/lib/tsan/rtl/tsan_defs.h
    compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc
    compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h
    compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc
    compiler-rt/trunk/lib/tsan/rtl/tsan_stat.cc

Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_defs.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_defs.h?rev=229112&r1=229111&r2=229112&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_defs.h (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_defs.h Fri Feb 13 09:25:47 2015
@@ -65,12 +65,6 @@ const bool kCollectHistory = false;
 const bool kCollectHistory = true;
 #endif
 
-#if defined(TSAN_COLLECT_STATS) && TSAN_COLLECT_STATS
-const bool kCollectStats = true;
-#else
-const bool kCollectStats = false;
-#endif
-
 // The following "build consistency" machinery ensures that all source files
 // are built in the same configuration. Inconsistent builds lead to
 // hard to debug crashes.

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=229112&r1=229111&r2=229112&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc Fri Feb 13 09:25:47 2015
@@ -394,8 +394,11 @@ int Finalize(ThreadState *thr) {
 
   failed = OnFinalize(failed);
 
+#ifdef TSAN_COLLECT_STATS
   StatAggregate(ctx->stat, thr->stat);
   StatOutput(ctx->stat);
+#endif
+
   return failed ? flags()->exitcode : 0;
 }
 

Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h?rev=229112&r1=229111&r2=229112&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h Fri Feb 13 09:25:47 2015
@@ -351,7 +351,9 @@ struct ThreadState {
   Vector<JmpBuf> jmp_bufs;
   int ignore_interceptors;
 #endif
+#ifdef TSAN_COLLECT_STATS
   u64 stat[StatCnt];
+#endif
   const int tid;
   const int unique_id;
   bool in_symbolizer;
@@ -539,15 +541,22 @@ void ObtainCurrentStack(ThreadState *thr
 }
 
 
+#ifdef TSAN_COLLECT_STATS
 void StatAggregate(u64 *dst, u64 *src);
 void StatOutput(u64 *stat);
+#endif
+
 void ALWAYS_INLINE StatInc(ThreadState *thr, StatType typ, u64 n = 1) {
+#ifdef TSAN_COLLECT_STATS
   if (kCollectStats)
     thr->stat[typ] += n;
+#endif
 }
 void ALWAYS_INLINE StatSet(ThreadState *thr, StatType typ, u64 n) {
+#ifdef TSAN_COLLECT_STATS
   if (kCollectStats)
     thr->stat[typ] = n;
+#endif
 }
 
 void MapShadow(uptr addr, uptr size);

Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc?rev=229112&r1=229111&r2=229112&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc Fri Feb 13 09:25:47 2015
@@ -145,7 +145,9 @@ void ThreadContext::OnFinished() {
   AllocatorThreadFinish(thr);
 #endif
   thr->~ThreadState();
+#ifdef TSAN_COLLECT_STATS
   StatAggregate(ctx->stat, thr->stat);
+#endif
   thr = 0;
 }
 

Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_stat.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_stat.cc?rev=229112&r1=229111&r2=229112&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_stat.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_stat.cc Fri Feb 13 09:25:47 2015
@@ -15,6 +15,8 @@
 
 namespace __tsan {
 
+#ifdef TSAN_COLLECT_STATS
+
 void StatAggregate(u64 *dst, u64 *src) {
   if (!kCollectStats)
     return;
@@ -176,4 +178,6 @@ void StatOutput(u64 *stat) {
     Printf("%s: %16zu\n", name[i], (uptr)stat[i]);
 }
 
+#endif
+
 }  // namespace __tsan





More information about the llvm-commits mailing list