Skip to content

Use gauges instead of counters for GC Pause Total and Num GCs#174

Closed
miguelmolina95 wants to merge 2 commits intomasterfrom
gauges
Closed

Use gauges instead of counters for GC Pause Total and Num GCs#174
miguelmolina95 wants to merge 2 commits intomasterfrom
gauges

Conversation

@miguelmolina95
Copy link
Copy Markdown

First of a series of fixes to make the obs of Go runtime stats better: WIP doc https://docs.google.com/document/d/1qGNgOgRV1FEuMlXIy0vzEvKdqRXYlYLGONaI0czs5d8/edit?tab=t.0

First issue we found is a couple of counters that are being misused and leading to an unbounded increment and then being divided by itself leading to a 1 value all the time.

Example with Etaproxy

If you look at the 2 counters we are changing right now and check the units you can see how they are growing unbounded and why gauge might be better:

pauseTotalNs: https://alerts.lyft.net/chart_v2/c6u11FIXgf?qs=%7B%22t%22%3A%7B%22startTimeMs%22%3A1747242870566%2C%22endTimeMs%22%3A1747249917735%7D%2C%22s%22%3A%5B%5D%7D

numGC: https://alerts.lyft.net/chart_v2/mTZNYUVfav?qs=%7B%22t%22%3A%7B%22startTimeMs%22%3A1747242881886%2C%22endTimeMs%22%3A1747249889433%7D%2C%22s%22%3A%5B%5D%7D

@miguelmolina95
Copy link
Copy Markdown
Author

meow #dev-go @connor15mcc

Comment thread runtime.go
lastGC: scope.NewGauge("lastGC"),
pauseTotalNs: scope.NewCounter("pauseTotalNs"),
numGC: scope.NewCounter("numGC"),
pauseTotalNs: scope.NewGauge("pauseTotalNs"),
Copy link
Copy Markdown

@abhinavdahiya abhinavdahiya May 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://cs.opensource.google/go/go/+/refs/tags/go1.24.3:src/runtime/mstats.go;l=258-263

// PauseTotalNs is the cumulative nanoseconds in GC
// stop-the-world pauses since the program started

so pauseTotalNs is not a gauge, it is actually a counter

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I think we were looking at one of the broken charts wrong and the reason it was broken I gave more context in the thread https://lyft.slack.com/archives/C0KLXB3KN/p1747250876491629 and updated the doc

@miguelmolina95
Copy link
Copy Markdown
Author

closing this with context on thread https://lyft.slack.com/archives/C0KLXB3KN/p1747250876491629 as we will fix the charts first

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants