You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
go version devel +91a5f16ce2 Sun Jan 29 22:47:27 2017 -0500 linux/amd64 (roughly Go 1.8)
Currently the garbage collector scans the pending finalizers queue during mark termination. The length of this queue is under user control and also never shrinks from the maximum number of queued finalizers over the life of the process.
The STW time on my laptop is about (20ns * Q + 1ns * (M - Q)) where Q is the current number of queued finalizers and M is the maximum number of finalizers that were ever queued. These constants are quite small, but the following ridiculous example demonstrates how to use this to drive up the STW time quite high:
package main
import"runtime"varsinkinterface{}
// active controls whether finalizers should be left on the queue or// not.constactive=truefuncmain() {
// Create a lot of objects with finalizers.objs:=make([]*byte, 1000000)
fori:=rangeobjs {
obj:=new(byte)
runtime.SetFinalizer(obj, func(x*byte) {
ifactive {
select {}
}
})
objs[i] =obj
}
// Release all of the objects.objs=nilif!active {
// Clear the finalizers queue.runtime.GC()
}
// Run GC.for {
sink=make([]byte, 1<<20)
}
}
The text was updated successfully, but these errors were encountered:
What version of Go are you using (
go version
)?go version devel +91a5f16ce2 Sun Jan 29 22:47:27 2017 -0500 linux/amd64 (roughly Go 1.8)
Currently the garbage collector scans the pending finalizers queue during mark termination. The length of this queue is under user control and also never shrinks from the maximum number of queued finalizers over the life of the process.
The STW time on my laptop is about (20ns * Q + 1ns * (M - Q)) where Q is the current number of queued finalizers and M is the maximum number of finalizers that were ever queued. These constants are quite small, but the following ridiculous example demonstrates how to use this to drive up the STW time quite high:
The text was updated successfully, but these errors were encountered: