這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。
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.
測試程式通過後,直接部署到線了,過了半天發現記憶體吃沒了
TOP
後來把 -race選項去掉就好了,還是理解不透,汗!
去掉後線上響應也正常了
回應時間