On Fri, Nov 1, 2024 at 9:15 PM Siyuan Liu <liusy...@gmail.com> wrote: > > There is this strange behavior on a Golang service we are running. > > On some instances, there is a forced GC that gets triggered every 4 minutes. > This can be observed when the `GODEBUG=gctrace=1` is turned on. There is a > log line with `gc ... (forced)` every 4 minutes consistently on selected > instances, with a few seconds off on each occurrence. It does not happen on > all instances. > > Based on the official golang documentation, `(forced)` is an indication that > `runtime.GC()` is forcefully triggered by the application code, however, > there is NO application code or third-party library code that does > `runtime.GC()`. > > I am wondering if golang internally does anything that might have triggered > the `runtime.GC()` - a.k.a - periodically forced GC operation? > > The log line that appears every 4 minutes looks something like: > "gc 2009 @96075.949s 0%: 0.65+1314+0.13 ms clock, 39+0/19595/54342+8.2 ms > cpu, 79719->80556->42707 MB, 123241 MB goal, 2 MB stacks, 1 MB globals, 60 P > (forced)"
Yes, in general a Go program will force a GC to occur if it has gone 2 minutes without doing any GC at all. I'm not sure why you are seeing a 4 minute period, though it's possible that I've misunderstood the code. Ian -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/golang-nuts/CAOyqgcUJx-CmRMeKFDgkSpYaNxQjE%2BHja-fP_0gz0ArDhEBcZQ%40mail.gmail.com.