[PATCH] D83625: [TSan] Optimize handling of racy address
Joachim Protze via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 11 08:10:26 PDT 2020
protze.joachim created this revision.
protze.joachim added reviewers: kcc, dvyukov.
protze.joachim added a project: Sanitizers.
Herald added a reviewer: jdoerfert.
Herald added subscribers: Sanitizers, sstefan1.
This patch splits the handling of racy address and racy stack into separate functions. If a race was already reported for the address, we can avoid the cost for collecting the involved stacks.
This patch also removes the race condition in storing the racy address / racy stack. This race allows all threads to report the race. Because all threads get the read lock first, it is quite probable that they all finish the lookup before one thread gets the chance to aquire the write lock.
For certain data race patterns in OpenMP programs, this patch significantly reduces the execution time. As an example the execution times for below code:
master (report_bugs=1): real 0m24s
master (report_bugs=0): real 0m0.2s
patch (report_bugs=1): real 0m0.5s
patch (report_bugs=0): real 0m0.2s
#include <stdio.h>
int main(void)
{
long sum=0;
#pragma omp parallel num_threads(4) //reduction(+:sum)
for(int i=0; i<1000000; i++)
{
sum++;
}
printf("Sum: %ld\n",sum);
}
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D83625
Files:
compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83625.277242.patch
Type: text/x-patch
Size: 4173 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200711/4e5ae9ec/attachment.bin>
More information about the llvm-commits
mailing list