Skip to content
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

sql: add metrics for prepared statement memory usage #97590

Merged
merged 1 commit into from
Feb 24, 2023

Conversation

michae2
Copy link
Collaborator

@michae2 michae2 commented Feb 23, 2023

Add node-level metrics for memory used by prepared statements across all sessions.

Assists: #72581

Epic: None

Release note (ui change): Add the following new metrics to track memory usage of prepared statements in sessions:

  • sql.mem.internal.session.prepared.current
  • sql.mem.internal.session.prepared.max-avg
  • sql.mem.internal.session.prepared.max-count
  • sql.mem.internal.session.prepared.max-max
  • sql.mem.internal.session.prepared.max-p50
  • sql.mem.internal.session.prepared.max-p75
  • sql.mem.internal.session.prepared.max-p90
  • sql.mem.internal.session.prepared.max-p99
  • sql.mem.internal.session.prepared.max-p99.9
  • sql.mem.internal.session.prepared.max-p99.99
  • sql.mem.internal.session.prepared.max-p99.999
  • sql.mem.sql.session.prepared.current
  • sql.mem.sql.session.prepared.max-avg
  • sql.mem.sql.session.prepared.max-count
  • sql.mem.sql.session.prepared.max-max
  • sql.mem.sql.session.prepared.max-p50
  • sql.mem.sql.session.prepared.max-p75
  • sql.mem.sql.session.prepared.max-p90
  • sql.mem.sql.session.prepared.max-p99
  • sql.mem.sql.session.prepared.max-p99.9
  • sql.mem.sql.session.prepared.max-p99.99
  • sql.mem.sql.session.prepared.max-p99.999

@blathers-crl
Copy link

blathers-crl bot commented Feb 23, 2023

It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR?

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@michae2
Copy link
Collaborator Author

michae2 commented Feb 23, 2023

Needs tests, but here's the general idea.

Copy link
Member

@yuzefovich yuzefovich left a comment

Choose a reason for hiding this comment

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

:lgtm:

I'll leave it up to you in terms of tests, I'd be ok with no explicit tests for this. I only recall having a test about all metrics mentioned in some chart catalog somewhere.

Reviewed 3 of 3 files at r1, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @DrewKimball, @michae2, and @rharding6373)


pkg/sql/mem_metrics.go line 117 at r1 (raw file):

			Buckets:  metric.MemoryUsage64MBBuckets}),
		SessionCurBytesCount: metric.NewGauge(MetaMemSessionCurBytes),
		SessionPreparedMaxBytesHist: metric.NewHistogram(metric.HistogramOptions{

nit: it might be nice to extract a small helper to construct this object to avoid some of the code duplication.

Copy link
Collaborator

@DrewKimball DrewKimball left a comment

Choose a reason for hiding this comment

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

:lgtm: Nice!

Reviewed 2 of 3 files at r1, all commit messages.
Reviewable status: :shipit: complete! 2 of 0 LGTMs obtained (waiting on @michae2 and @rharding6373)

@michae2 michae2 requested a review from a team February 24, 2023 00:30
Add node-level metrics for memory used by prepared statements across all
sessions.

Assists: cockroachdb#72581

Epic: None

Release note (ui change): Add the following new metrics to track memory
usage of prepared statements in sessions:
- sql.mem.internal.session.prepared.current
- sql.mem.internal.session.prepared.max-avg
- sql.mem.internal.session.prepared.max-count
- sql.mem.internal.session.prepared.max-max
- sql.mem.internal.session.prepared.max-p50
- sql.mem.internal.session.prepared.max-p75
- sql.mem.internal.session.prepared.max-p90
- sql.mem.internal.session.prepared.max-p99
- sql.mem.internal.session.prepared.max-p99.9
- sql.mem.internal.session.prepared.max-p99.99
- sql.mem.internal.session.prepared.max-p99.999
- sql.mem.sql.session.prepared.current
- sql.mem.sql.session.prepared.max-avg
- sql.mem.sql.session.prepared.max-count
- sql.mem.sql.session.prepared.max-max
- sql.mem.sql.session.prepared.max-p50
- sql.mem.sql.session.prepared.max-p75
- sql.mem.sql.session.prepared.max-p90
- sql.mem.sql.session.prepared.max-p99
- sql.mem.sql.session.prepared.max-p99.9
- sql.mem.sql.session.prepared.max-p99.99
- sql.mem.sql.session.prepared.max-p99.999
Copy link
Collaborator Author

@michae2 michae2 left a comment

Choose a reason for hiding this comment

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

I'll leave it up to you in terms of tests, I'd be ok with no explicit tests for this. I only recall having a test about all metrics mentioned in some chart catalog somewhere.

Ok, good point. Thank you!

bors r=yuzefovich,DrewKimball

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 2 stale) (waiting on @rharding6373 and @yuzefovich)


pkg/sql/mem_metrics.go line 117 at r1 (raw file):

Previously, yuzefovich (Yahor Yuzefovich) wrote…

nit: it might be nice to extract a small helper to construct this object to avoid some of the code duplication.

Done.

@craig
Copy link
Contributor

craig bot commented Feb 24, 2023

Build succeeded:

@craig craig bot merged commit e7c2286 into cockroachdb:master Feb 24, 2023
@blathers-crl
Copy link

blathers-crl bot commented Feb 24, 2023

Encountered an error creating backports. Some common things that can go wrong:

  1. The backport branch might have already existed.
  2. There was a merge conflict.
  3. The backport branch contained merge commits.

You might need to create your backport manually using the backport tool.


error creating merge commit from aa31d92 to blathers/backport-release-22.1-97590: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict []

you may need to manually resolve merge conflicts with the backport tool.

Backport to branch 22.1.x failed. See errors above.


🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

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.

4 participants