-
Notifications
You must be signed in to change notification settings - Fork 18k
runtime/race: MemoryRangeSet is slow #20139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
We can try to replace kGoMode (which is now SANITIZER_GO) with SANITIZER_WINDOWS. |
Great! If I want to try that out, are there docs anywhere for how to update the race detector? I'm looking for basic things like: where to get the tsan code, which branch/commit to use, pointer to docs about how to build the tsan Go support libs, where to find the build artifacts, where to put them in the Go tree, how to test. |
src/runtime/race/README is meant to drive you in the right direction |
Thanks. I'm busy fixing races at the moment, but will give it a try soon. :) |
Thanks for the pointer, @dvyukov. Switching to SANITIZER_WINDOWS helps a little with performance, but not much:
So I think I'll send a patch upstream but not bother trying to get the race libraries updated ahead of schedule. (When is schedule, anyway?) |
Blarg. Can't figure out where and how to send compiler-rt patches. @dvyukov the patch would be going to you anyway. Can you just apply it from here? (Or recreate it locally?) It's pretty trivial. From d3c800fb4e7b475f6aa6a284676a503e5735cca3 Mon Sep 17 00:00:00 2001
From: Josh Bleecher Snyder <josharian@gmail.com>
Date: Tue, 2 May 2017 07:33:31 -0700
Subject: [PATCH] tsan: allow fast large MemoryRangeSet on non-Windows Go
See https://github.com/golang/go/issues/20139
for background and motivation.
---
lib/tsan/rtl/tsan_rtl.cc | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/lib/tsan/rtl/tsan_rtl.cc b/lib/tsan/rtl/tsan_rtl.cc
index 70393037e..fa60f3247 100644
--- a/lib/tsan/rtl/tsan_rtl.cc
+++ b/lib/tsan/rtl/tsan_rtl.cc
@@ -866,9 +866,8 @@ static void MemoryRangeSet(ThreadState *thr, uptr pc, uptr addr, uptr size,
// Don't want to touch lots of shadow memory.
// If a program maps 10MB stack, there is no need reset the whole range.
size = (size + (kShadowCell - 1)) & ~(kShadowCell - 1);
- // UnmapOrDie/MmapFixedNoReserve does not work on Windows,
- // so we do it only for C/C++.
- if (SANITIZER_GO || size < common_flags()->clear_shadow_mmap_threshold) {
+ // UnmapOrDie/MmapFixedNoReserve does not work on Windows.
+ if (SANITIZER_WINDOWS || size < common_flags()->clear_shadow_mmap_threshold) {
u64 *p = (u64*)MemToShadow(addr);
CHECK(IsShadowMem((uptr)p));
CHECK(IsShadowMem((uptr)(p + size * kShadowCnt / kShadowCell - 1)));
--
2.12.2
|
Done http://llvm.org/viewvc/llvm-project?view=revision&revision=301927 |
The fast reset for large memory regions is not working only on windows. So enable it for Go/linux/darwin/freebsd. See golang/go#20139 for background and motivation. Based on idea by Josh Bleecher Snyder. llvm-svn=301927
Yep, insofar as I know how. |
Thanks! I'll close this now. |
The race-enabled compiler (
go install -race cmd/compile
) spends 40% of its CPU time in __tsan MemoryRangeSet. Looking at the implementation of MemoryRangeSet in tsan_rtl.cc, I see (roughly):The compiler does lots of large, bulk memory clears. I wonder whether the
kGoMode ||
part of the conditional could be removed.cc @dvyukov
The text was updated successfully, but these errors were encountered: