Hacker News new | past | comments | ask | show | jobs | submit login

When GOMAXPROCS > 1, your program goes from "everything is executed sequentially" to "everything is maybe executed in parallel." This can expose data race bugs in your code that aren't present when GOMAXPROCS = 1.

(I'd suggest using Go's race detector.)




You know, that's entirely possible. I was playing around with different methods of passing data between goroutines for increasing performance and I knew one of the methods I was testing wasn't idiomatic Go. However since I wasn't getting race conditions normally i assumed that the GOMAXPROCS fault wasn't down to my shonky code.

The weird thing is I thought I'd read somewhere that said Go defaulted to a process per CPU core (like the OP has hardcoded ib this project). I'm guessing that isn't the case then? It sadly wouldn't be the first time I've misread something! :(


GOMAXPROCS defaults to 1, meaning unless you change that value, your code will not run in parallel by default.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: