Go1.6 放出来很久了,这里是 Release,比较注意一点 Map 不加锁在并发访问时会 Crash.
先说问题:升级go1.6后,线上的GC时间显显变短,但是响应时间变大,不可接受。
显显看到 小于1ms的请求大幅减少,1ms~10ms请求突增,如果每个请求1ms,整体QPS猛降到1000,完全不能接受。
系统日志看升级后延迟好大
对比升级前的响应,基本不到1ms
不知道已入坑的同学,有无遇到这个问题。在官方的 Issues 也提到过,需要进一步的测试
疑似内存泄漏问题20160315
因为升级go1.6有一个map并发访问的问题,所以在 go install 的时间增加了 -race选项
The runtime has added lightweight, best-effort detection of concurrent misuse of maps. As always, if one goroutine is writing to a map, no other goroutine should be reading or writing the map concurrently. If the runtime detects this condition, it prints a diagnosis and crashes the program. The best way to find out more about the problem is to run it under therace detector, which will more reliably identify the race and give more detail.
The compiler, linker, and go command have a new-msanflag analogous to -race and only available on linux/amd64, that enables interoperation with theClang MemorySanitizer. This is useful for testing a program containing suspect C or C++ code. You might like to try it while testing your cgo code with the new pointer rules.
测试程序通过后,直接部署到线了,过了半天发现内存吃没了
后来把 -race选项去掉就好了,还是理解不透,汗!
去掉后线上响应也正常了
有疑问加站长微信联系(非本文作者)