gopkg
gopkg copied to clipboard
gc tunner not Use in not web application
Operating System
Linux
Go Version
go version go1.16.15 darwin/amd64
Package Version
develop
Affected Packages
gctunner
Expected Behavior
use GODEBUG=gctrace=1 go run main.go
to start
want see gc not frequent
Actual Behavior
gc frequent gc 1 @1.007s 0%: 0.015+0.21+0.018 ms clock, 0.18+0.11/0.13/0.072+0.21 ms cpu, 4->4->0 MB, 5 MB goal, 12 P gc 2 @1.017s 0%: 0.011+0.19+0.016 ms clock, 0.14+0.076/0.099/0.009+0.19 ms cpu, 20->20->0 MB, 21 MB goal, 12 P gc 3 @1.021s 0%: 0.010+0.28+0.047 ms clock, 0.12+0.061/0.076/0.012+0.56 ms cpu, 20->20->0 MB, 21 MB goal, 12 P gc 4 @1.025s 0%: 0.009+0.19+0.027 ms clock, 0.11+0.065/0.071/0.029+0.33 ms cpu, 20->20->0 MB, 21 MB goal, 12 P gc 5 @1.028s 0%: 0.008+0.21+0.014 ms clock, 0.10+0.059/0.16/0.048+0.17 ms cpu, 20->20->0 MB, 21 MB goal, 12 P gc 6 @1.032s 0%: 0.010+0.17+0.027 ms clock, 0.12+0.075/0.065/0.007+0.32 ms cpu, 20->20->0 MB, 21 MB goal, 12 P gc 7 @1.035s 0%: 0.009+0.15+0.019 ms clock, 0.11+0.056/0.061/0.006+0.23 ms cpu, 20->20->0 MB, 21 MB goal, 12 P gc 8 @1.039s 0%: 0.009+0.17+0.018 ms clock, 0.11+0.055/0.084/0.005+0.21 ms cpu, 20->20->0 MB, 21 MB goal, 12 P gc 9 @1.042s 0%: 0.008+0.17+0.059 ms clock, 0.10+0.054/0.059/0.002+0.71 ms cpu, 20->20->0 MB, 21 MB goal, 12 P
Reproduction Steps
- run following code
package main
import (
"global/gctuner"
)
func main() {
const gb = 1024 * 1024 * 1024
threshold := gb * 4
gctuner.Tuning(uint64(threshold))
println(gctuner.GetGCPercent())
// 执行具体的业务逻辑
for {
data1 := make([]int, 10000, 10000)
data2 := make([]int, 10000, 10000)
for i, _ := range data1 {
data1[i] = i
}
for i, _ := range data2 {
data2[i] = i
}
result := 0
for i, _ := range data1 {
result += data1[i] * data2[i]
}
}
}
- Then run it with command, You will see the gc info
GODEBUG=gctrace=1 go run main.go
Other Information
No response