summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common/sanitizer_suppressions.cc
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2015-09-03 11:20:46 +0000
committerDmitry Vyukov <dvyukov@google.com>2015-09-03 11:20:46 +0000
commit06530fab36e4c670299d5869602f3f435488ff5e (patch)
treee9ca794ef27473ab0ac09e3dc66ca73972c35687 /lib/sanitizer_common/sanitizer_suppressions.cc
parent2f398402dd3aef14ac764a33b726f1a483d7959e (diff)
tsan: speed up race deduplication
Race deduplication code proved to be a performance bottleneck in the past if suppressions/annotations are used, or just some races left unaddressed. And we still get user complaints about this: https://groups.google.com/forum/#!topic/thread-sanitizer/hB0WyiTI4e4 ReportRace already has several layers of caching for racy pcs/addresses to make deduplication faster. However, ReportRace still takes a global mutex (ThreadRegistry and ReportMutex) during deduplication and also calls mmap/munmap (which take process-wide semaphore in kernel), this makes deduplication non-scalable. This patch moves race deduplication outside of global mutexes and also removes all mmap/munmap calls. As the result, race_stress.cc with 100 threads and 10000 iterations become 30x faster: before: real 0m21.673s user 0m5.932s sys 0m34.885s after: real 0m0.720s user 0m23.646s sys 0m1.254s http://reviews.llvm.org/D12554 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@246758 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common/sanitizer_suppressions.cc')
-rw-r--r--lib/sanitizer_common/sanitizer_suppressions.cc6
1 files changed, 2 insertions, 4 deletions
diff --git a/lib/sanitizer_common/sanitizer_suppressions.cc b/lib/sanitizer_common/sanitizer_suppressions.cc
index 2b91fbfe9..46d463813 100644
--- a/lib/sanitizer_common/sanitizer_suppressions.cc
+++ b/lib/sanitizer_common/sanitizer_suppressions.cc
@@ -127,13 +127,11 @@ void SuppressionContext::Parse(const char *str) {
Printf("%s: failed to parse suppressions\n", SanitizerToolName);
Die();
}
- Suppression s;
+ Suppression s = {};
s.type = suppression_types_[type];
s.templ = (char*)InternalAlloc(end2 - line + 1);
internal_memcpy(s.templ, line, end2 - line);
s.templ[end2 - line] = 0;
- s.hit_count = 0;
- s.weight = 0;
suppressions_.push_back(s);
has_suppression_type_[type] = true;
}
@@ -163,7 +161,7 @@ const Suppression *SuppressionContext::SuppressionAt(uptr i) const {
void SuppressionContext::GetMatched(
InternalMmapVector<Suppression *> *matched) {
for (uptr i = 0; i < suppressions_.size(); i++)
- if (suppressions_[i].hit_count)
+ if (atomic_load_relaxed(&suppressions_[i].hit_count))
matched->push_back(&suppressions_[i]);
}