-
Notifications
You must be signed in to change notification settings - Fork 17.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
runtime: API for unstable metrics #37112
Comments
Change https://golang.org/cl/218677 mentions this issue: |
@mknyszek, what's the status of this? Is the doc ready for review and discussion (if so please check it in)? |
The doc is ready for review and discussion, I just don't have +2 or a review to land it yet. I'll try to ping more people to look at the CL. |
This change adds a proposal and design document for addition of a runtime metrics package which is designed to support adding and removing runtime metrics without breaking the Go 1 compatibility promise. Updates golang/go#37112. Change-Id: I550740970ad74c5c71d712735e4984808bdbf463 Reviewed-on: https://go-review.googlesource.com/c/proposal/+/218677 Reviewed-by: Austin Clements <austin@google.com>
A couple of high-level comments:
|
Actually, perhaps the |
Given that we probably need to copy data out of the runtime anyway, I think you're right that it makes sense to just have concrete types.
I considered including type information in the Metric in order to let users filter out metrics they don't understand, and I'm certainly not opposed. An allocation function is also a neat idea. One less potential footgun, but it is more work the user has to do to set this all up. |
It may also be worthwhile to have (I could imagine that someone might try to call |
I know there are minor details still being worked out, like whether Read returns an error in some cases. Other than those, it seems like people are generally in favor of this proposal. Am I reading this wrong? Does anyone object to accepting this proposal? |
OK, then based on the discussion above this seems like a likely accept. |
No change in consensus, so accepted. |
Change https://golang.org/cl/247041 mentions this issue: |
Change https://golang.org/cl/247040 mentions this issue: |
Change https://golang.org/cl/247045 mentions this issue: |
Change https://golang.org/cl/247049 mentions this issue: |
Change https://golang.org/cl/247047 mentions this issue: |
Change https://golang.org/cl/247046 mentions this issue: |
Change https://golang.org/cl/247043 mentions this issue: |
Change https://golang.org/cl/247044 mentions this issue: |
Oops, I totally forgot about this. Luckily, the case you're worried about came up in the intervening months, and the way I addressed it is by making the resulting |
This change creates the runtime/metrics package and adds the initial interface as laid out in the design document. For #37112. Change-Id: I202dcee08ab008dd63bf96f7a4162f5b5f813637 Reviewed-on: https://go-review.googlesource.com/c/go/+/247040 Run-TryBot: Michael Knyszek <mknyszek@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Michael Knyszek <mknyszek@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
This change adds support for a variety of runtime memory metrics and contains the base implementation of Read for the runtime/metrics package, which lives in the runtime. It also adds testing infrastructure for the metrics package, and a bunch of format and documentation tests. For #37112. Change-Id: I16a2c4781eeeb2de0abcb045c15105f1210e2d8a Reviewed-on: https://go-review.googlesource.com/c/go/+/247041 Run-TryBot: Michael Knyszek <mknyszek@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com> Trust: Michael Knyszek <mknyszek@google.com>
For #37112. Change-Id: Idd3dd5c84215ddd1ab05c2e76e848aa0a4d40fb0 Reviewed-on: https://go-review.googlesource.com/c/go/+/247043 Run-TryBot: Michael Knyszek <mknyszek@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Michael Knyszek <mknyszek@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
This change adds three new metrics: the heap goal, GC cycle count, and forced GC count. These metrics are identical to their MemStats counterparts. For #37112. Change-Id: I5a5e8dd550c0d646e5dcdbdf38274895e27cdd88 Reviewed-on: https://go-review.googlesource.com/c/go/+/247044 Run-TryBot: Michael Knyszek <mknyszek@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Michael Knyszek <mknyszek@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
This change adds metrics for the distribution of objects allocated and freed by size, mirroring MemStats' BySize field. For #37112. Change-Id: Ibaf1812da93598b37265ec97abc6669c1a5efcbf Reviewed-on: https://go-review.googlesource.com/c/go/+/247045 Run-TryBot: Michael Knyszek <mknyszek@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Michael Knyszek <mknyszek@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
This change adds a concurrent HDR time histogram to the runtime with tests. It also adds a function to generate boundaries for use by the metrics package. For #37112. Change-Id: Ifbef8ddce8e3a965a0dcd58ccd4915c282ae2098 Reviewed-on: https://go-review.googlesource.com/c/go/+/247046 Run-TryBot: Michael Knyszek <mknyszek@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Michael Knyszek <mknyszek@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
For #37112. Change-Id: Ibb0425c9c582ae3da3b2662d5bbe830d7df9079c Reviewed-on: https://go-review.googlesource.com/c/go/+/247047 Run-TryBot: Michael Knyszek <mknyszek@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Michael Knyszek <mknyszek@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
For #37112. Change-Id: I994dfe848605b95ef6aec24f53869e929247e987 Reviewed-on: https://go-review.googlesource.com/c/go/+/247049 Run-TryBot: Michael Knyszek <mknyszek@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Michael Knyszek <mknyszek@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
|
Would it be possible to update the proposal and the documentation describing the relationship between
Now it feels confusing why std has two ways of exposing its internal stats. |
@narqo Yeah, I'm happy to update both the proposal and the documentation. I'll make sure it happens before the release. The short answer to the relationship between the two is that Another point here is that despite its use of string keys, I filed another issue to try to figure out how Thank you for your input here, and please feel free to start/continue the discussion on #43555. |
Proposal: API for unstable runtime metrics
Background & Motivation
Today runtime metrics are exposed in two ways.
The first way is via the struct-based sampling APIs
runtime.ReadMemStats
andruntime/debug.GCStats
. These functions accept a pointer to a struct and then populate the struct with data from the runtime.The problems with this type of API are:
MemStats.BySize
is hard-coded to 61 size classes when there are currently 83. We cannot ever changeBySize
.runtime.ReadMemStats
has a global effect on the application because it forces a STW. This has a direct effect on latency. Being able to tease apart which metrics actually need gives users more control over performance.The good things about this type of API are:
The second is via
GODEBUG
flags which emit strings containing metrics to standard error (e.g.gctrace
,gcpacertrace
,scavtrace
).The problems with this type of API are:
The good things about this type of API are:
I would like to propose a new API which takes the best of both approaches.
Requirements
affect any of the metrics being measured.
Goals
Given the requirements, I suggest we prioritize the following concerns when designing the API in the following order.
Design
See full design document at https://golang.org/design/37112-unstable-runtime-metrics.
Highlights:
runtime/metrics
package.Backwards Compatibility
Note that although the set of metrics the runtime exposes will not be stable across Go versions, the API to discover and access those metrics will be.
Therefore, this proposal strictly increases the API surface of the Go standard library without changing any existing functionality and is therefore Go 1 compatible.
The text was updated successfully, but these errors were encountered: