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

pageserver: add per-timeline read amp histogram #10566

Merged
merged 1 commit into from
Jan 30, 2025

Conversation

erikgrinaker
Copy link
Contributor

@erikgrinaker erikgrinaker commented Jan 29, 2025

Problem

We don't have per-timeline observability for read amplification.

Touches https://github.com/neondatabase/cloud/issues/23283.

Summary of changes

Add a per-timeline pageserver_layers_per_read histogram.

NB: per-timeline histograms are expensive, but probably worth it in this case.

@erikgrinaker erikgrinaker requested a review from a team as a code owner January 29, 2025 17:31
@erikgrinaker erikgrinaker changed the title pageserver: improve read amp metric pageserver: improve layers per read metric Jan 29, 2025
Copy link
Member

@skyzh skyzh left a comment

Choose a reason for hiding this comment

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

Need to check with infra team if they are fine with a per-timeline histogram, I remembered it overloaded the metrics system before. (i.e., it would take a minute to scrape pageserver metrics)

Copy link

github-actions bot commented Jan 29, 2025

7414 tests run: 7063 passed, 0 failed, 351 skipped (full report)


Flaky tests (8)

Postgres 17

Code coverage* (full report)

  • functions: 33.4% (8511 of 25500 functions)
  • lines: 49.1% (71477 of 145523 lines)

* collected from Rust tests only


The comment gets automatically updated with the latest test results
8617a8d at 2025-01-30T11:32:48.632Z :recycle:

@erikgrinaker erikgrinaker force-pushed the erik/layers-per-read-metric branch from d302445 to f368c55 Compare January 29, 2025 21:34
@erikgrinaker erikgrinaker changed the base branch from main to erik/layers-per-read-global January 29, 2025 21:34
@erikgrinaker
Copy link
Contributor Author

erikgrinaker commented Jan 29, 2025

I split out the fix of the global pageserver_layers_per_read_global metric to #10573, and kept this only for the per-timeline metric, to discuss if the cardinality is worth it. Will revisit tomorrow.

@erikgrinaker erikgrinaker changed the title pageserver: improve layers per read metric pageserver: add per-timeline read amp metric Jan 29, 2025
@erikgrinaker erikgrinaker changed the title pageserver: add per-timeline read amp metric pageserver: add per-timeline read amp histogram Jan 29, 2025
github-merge-queue bot pushed a commit that referenced this pull request Jan 30, 2025
## Problem

The current global `pageserver_layers_visited_per_vectored_read_global`
metric does not appear to accurately measure read amplification. It
divides the layer count by the number of reads in a batch, but this
means that e.g. 10 reads with 100 L0 layers will only measure a read amp
of 10 per read, while the actual read amp was 100.

While the cost of layer visits are amortized across the batch, and some
layers may not intersect with a given key, each visited layer
contributes directly to the observed latency for every read in the
batch, which is what we care about.

Touches neondatabase/cloud#23283.
Extracted from #10566.

## Summary of changes

* Count the number of layers visited towards each read in the batch,
instead of the average across the batch.
* Rename `pageserver_layers_visited_per_vectored_read_global` to
`pageserver_layers_per_read_global`.
* Reduce the read amp log warning threshold down from 512 to 100.
Base automatically changed from erik/layers-per-read-global to main January 30, 2025 09:35
@erikgrinaker erikgrinaker force-pushed the erik/layers-per-read-metric branch from f368c55 to 8617a8d Compare January 30, 2025 10:09
@erikgrinaker
Copy link
Contributor Author

To reduce the cardinality, I lowered the resolution here to:

[1.0, 5.0, 10.0, 25.0, 50.0, 100.0]

The global metric has slightly better resolution:

[1.0, 2.0, 4.0, 8.0, 16.0, 32.0, 64.0, 128.0, 256.0, 512.0, 1024.0]

I think that should be enough to give us a rough idea of timeline read amp. If the global metric shows e.g. >256, we can likely narrow it down to a handful of tenants with the per-timeline histogram.

I'm going to merge this as-is, we can always change/remove it later if we need to.

@erikgrinaker erikgrinaker added this pull request to the merge queue Jan 30, 2025
Merged via the queue into main with commit 6a2afa0 Jan 30, 2025
82 checks passed
@erikgrinaker erikgrinaker deleted the erik/layers-per-read-metric branch January 30, 2025 11:32
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.

2 participants