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

db/pebble: Extract Pebble's native metrics #1259

Open
wants to merge 29 commits into
base: main
Choose a base branch
from

Conversation

Exca-DK
Copy link
Contributor

@Exca-DK Exca-DK commented Sep 20, 2023

closes #1243

@codecov
Copy link

codecov bot commented Sep 20, 2023

Codecov Report

Attention: 11 lines in your changes are missing coverage. Please review.

Comparison is base (fe17176) 73.38% compared to head (f9743cb) 74.07%.

❗ Current head f9743cb differs from pull request most recent head 1f2b2ce. Consider uploading reports for the commit 1f2b2ce to get more accurate results

Files Patch % Lines
db/pebble/db_metrics.go 91.01% 7 Missing and 1 partial ⚠️
db/pebble/db.go 86.95% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1259      +/-   ##
==========================================
+ Coverage   73.38%   74.07%   +0.69%     
==========================================
  Files         101       81      -20     
  Lines       10320     8915    -1405     
==========================================
- Hits         7573     6604     -969     
+ Misses       2183     1815     -368     
+ Partials      564      496      -68     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

db/pebble/db.go Outdated Show resolved Hide resolved
@Exca-DK
Copy link
Contributor Author

Exca-DK commented Sep 26, 2023

I see that the overall metrics were refactored. Any changes you would want to see before I start adapting it to the new structure? I could also split this PR into smaller ones, each representing part of the pebble.metrics if that's helpful.

@omerfirmak
Copy link
Contributor

PR into smaller ones, each representing part of the pebble.metrics if that's helpful.

thanks, that would be great. separate commits are good enough, no need for multiple PRs.

@Exca-DK
Copy link
Contributor Author

Exca-DK commented Sep 27, 2023

@omerfirmak Would mind giving it a try? Just LevelsListener for now.

@Exca-DK Exca-DK marked this pull request as ready for review October 9, 2023 01:41
@Exca-DK
Copy link
Contributor Author

Exca-DK commented Oct 9, 2023

One thing to note: I added a hint about deriving some extra metrics from pebble events. Didn't go for that one in this PR as this PR is focused on just pebble.Metrics object. This pr foresees that it will be later implemented therefore some groundwork has been added in order to support the extension. That's also the reason why PebbleMetrics is passed around instead of just pebble.Metrics.

@omerfirmak
Copy link
Contributor

omerfirmak commented Oct 25, 2023

Sorry for the very late reply.

I think most of the metrics pebble exposes are way too specific to make any sense for us. We definitely don't need metrics from all the levels.

Let's do what geth does and only report a subset if you dont mind.
https://github.com/ethereum/go-ethereum/blob/a8617c6d4dbe0df8c67e1f5c2ecd76c3200dc18d/ethdb/pebble/pebble.go#L58-L70C27

@Exca-DK
Copy link
Contributor Author

Exca-DK commented Oct 26, 2023

Should be ready for review @omerfirmak

preview of metrics in dashboard during initial sync:
image

Comment on lines 47 to 55
// Create storage for delta calculation.
var (
compTimes [2]time.Duration
writeDelayCounts [2]uint64
writeDelayTimes [2]time.Duration
compWrites [2]uint64
compReads [2]uint64
nWrites [2]uint64
)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think you need to do this here, no? Delta calculation can be done on Grafana.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not sure. The data provided by Pebble is the total cumulative so far, and that sounds to me like a case for Counter with delta instead of only ever-increasing gauge. For example, compWrites and compReads represent bytes written and read during compactions. I haven't personally seen a bytes-written metric represented as a gauge or, even worse, a counter that adds the total instead of the change. go-ethereum also reports the delta for that, but they use a slightly different collector called meter, which, from what I understand, accumulates data and resets itself after taking a snapshot.

I've been thinking about whether memComps, lvl0Comps, nonLvl0Comps, and seekComps shouldn't be represented as counters with a delta, too, for that reason. That would leave us with only three gauges in total: DiskSize, LevelFiles, and ManualMemAlloc. They represent the current value and can decrease or increase between snapshots.

Copy link
Contributor

Choose a reason for hiding this comment

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

The data provided by Pebble is the total cumulative so far

That is entirely fine, prometheus counters are expected to monotonically increase. They shouldn't be decremented. Let's just export whatever pebble is reporting, I don't think we need to do delta calculation ourselves.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I exported them as they are. Would mind sharing some insights as to why the total? I am also not sure if I shouldn't change the counters into gauges with that change.

@Exca-DK
Copy link
Contributor Author

Exca-DK commented Oct 26, 2023

I added changes that align with the behavior described in comment.

@joshklop joshklop added this to the v0.9.3 milestone Jan 9, 2024
@Exca-DK
Copy link
Contributor Author

Exca-DK commented Jan 14, 2024

Hey @joshklop, I noticed you added this to the milestone. Do you want me to resolve the conflicts since this PR has been idle for some time already?

@joshklop
Copy link
Contributor

Hey @joshklop, I noticed you added this to the milestone. Do you want me to resolve the conflicts since this PR has been idle for some time already?

Hi @Exca-DK, that would be super helpful. Thanks for offering.

I think @omerfirmak had some opinions about how we should move forward on this PR, so I'll re-request a review from him.

@omerfirmak
Copy link
Contributor

Hey @joshklop, I noticed you added this to the milestone. Do you want me to resolve the conflicts since this PR has been idle for some time already?

Please do, we will try to get this merged soon. Sorry it took us so long:(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Review
Development

Successfully merging this pull request may close these issues.

Extract Pebble's native metrics
3 participants