6 ms·
Introducing the Go Race Detector
- AYBABTME 13y agoWas coming here to post just that! It's a really terrific tool, I'm really happy to see the Go team providing great default tools with the distribution.
- stevedomin 13y agoGo has such a great set of tools, it's definitely one of the reason I love it so much. The Go team did an amazing job on this.
- regecks 13y agoYes, this is pretty freaking cool. Hopefully it works on Windows too, which is my main OS when I'm working with Go. It seems Windows is a second class citizen when it comes to some of the toolchain (pprof is kinda broken, I can't get addresses to resolve to symbols and just end up profiling on Linux), but fingers crossed!
- enneff 13y agoIt does work on windows/amd64. We're trying hard to keep Windows well-supported. The pprof story is a little sad, as it was a very unix-centric tool to begin with.
- dualogy 13y ago> We're trying hard to keep Windows well-supported As another Go developer on Win7, thanks, I think a lot of people really do appreciate this. I've worked for years under Linux and OSX as well, but when I started dabbling in OpenGL via Go last year, I switched to Win7 for better nvidia gpu drivers (and Steam), simple as that. If you keep other MS crap I mean software off a Win7 system, it's a rock-solid developer OS with msys/mingw and Sublime Text and Go. I wouldn't touch Win8 but my 7 setup is absolutely working for me as of now. Ultimately I'll have to head back to a Unix seeing the direction Windows is taking, but I'm really happy to be able to work in Go as a first-class citizen for the time being. Also given today's prevalence of Unixes in developer circles, Win7 is ironically the only OS giving off that "bad-ass underdog" vibe..
- AndreasFrom 13y agoI made pprof work, on my machine at least, by replacing the Unix-style directories with Windows ones. /dev/null -> NUL and /tmp -> $ENV{'TEMP'} in the perl script.
- mattetti 13y ago"it is only as good as your tests; you must make sure they thoroughly exercise the concurrent properties of your code so that the race detector can do its job." <-- it's not a magical tool but man it's great to have such a tool, debugging concurrency bugs is a real pain.
- joelg236 13y agoThe more I read about it, the more I want to learn Go before C/C++. Is there any reason not to?
- enneff 13y agoIt will certainly take a lot less time to learn Go than C, and even moreso compared to C++.
- jamesaguilar 13y agoUnless you're building a database or a game, it's probably fast enough.
- talloaktrees 13y agoWhile I wouldn't use Go to make a game because of lack of good libraries/frameworks, performance is fine for less-demanding games (2d, stuff, minecraft, etc)
- benbjohnson 13y agoIt's worth noting to joelg236 that you can easily drop C into your Go program using CGO (http://golang.org/cmd/cgo/ http://golang.org/cmd/cgo/) for parts that need to be extremely performant. You incur a context switch overhead but it can really boost performance in some use cases.
- dom96 13y agoI would suggest learning Nimrod (http://nimrod-code.org http://nimrod-code.org) instead.
- rurban 13y agoI can wholeheartely recommend this tool. With tsan I found a lot of races in parrot threads, which I didn't detect in months before. Those were all real issues. http://blogs.perl.org/users/rurban/2012/08/threadsanitizer.html http://blogs.perl.org/users/rurban/2012/08/threadsanitizer.h...
- shurcooL 13y agoI feel like I've seen this some time ago, with the release of Go 1.1. Perhaps the article itself is new while what it describes isn't. It just feels very familiar despite the recent date.
- jzelinskie 13y agoThe race detector was introduced into stable with Go 1.1. This article is what's new, not the race detector.
- enneff 13y agoWe discussed the race detector in our Go 1.1 announcement blog post, but only very superficially. If you actually read this article there is an in-depth discussion of two real race conditions that were found by the tool.
- shurcooL 13y agoMakes sense; thanks.
- fmstephe 13y agoAs a side note the solution to the Discard problem is quite beautiful. https://code.google.com/p/go/source/detail?r=4b61f121966b https://code.google.com/p/go/source/detail?r=4b61f121966b As I read it makes a quick-try to acquire a pre-allocated buffer, otherwise makes its own. Then it makes a quick-try to give the buffer it used back (to be used by another goroutine). That is a very elegant use of channels to create an optimistic buffer. Enjoyed that read :)
- TheMagicHorsey 13y agoThe scary part about this is that I had two race conditions in my code, and they never manifested themselves when the code was live. They were just sort of lurking there. Now I'm paranoid about my non-Go code. Turns out I don't understand concurrent programming as well as I thought I did. Even when I thought I was being really disciplined and organized about my concurrency, I actually wasn't.