Skip to content

Conversation

@Kbhat1
Copy link
Contributor

@Kbhat1 Kbhat1 commented Oct 10, 2025

Describe your changes and provide context

  • Adds State Store Metrics for PebbleDB
  • Includes flush, compaction + api metrics (Get/ApplyChangeset/Iteration etc)

Testing performed to validate your change

  • Verifying on node

@codecov
Copy link

codecov bot commented Oct 10, 2025

Codecov Report

❌ Patch coverage is 97.83784% with 4 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@9264736). Learn more about missing BASE report.
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
sei-db/ss/pebbledb/db.go 98.09% 1 Missing and 1 partial ⚠️
sei-db/ss/pebbledb/metrics.go 50.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2463   +/-   ##
=======================================
  Coverage        ?   41.14%           
=======================================
  Files           ?     1602           
  Lines           ?   135020           
  Branches        ?        0           
=======================================
  Hits            ?    55560           
  Misses          ?    74373           
  Partials        ?     5087           
Flag Coverage Δ
sei-chain 27.87% <43.78%> (?)
sei-cosmos 52.37% <ø> (?)
sei-db 48.18% <85.94%> (?)
sei-wasmd 46.43% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
sei-db/sc/memiavl/db.go 67.33% <100.00%> (ø)
sei-db/sc/memiavl/metrics.go 50.00% <ø> (ø)
sei-db/sc/memiavl/multitree.go 76.44% <100.00%> (ø)
sei-db/ss/pebbledb/batch.go 77.90% <100.00%> (ø)
sei-db/ss/pebbledb/iterator.go 54.20% <100.00%> (ø)
sei-db/ss/pebbledb/db.go 67.77% <98.09%> (ø)
sei-db/ss/pebbledb/metrics.go 50.00% <50.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Kbhat1 Kbhat1 requested review from jewei1997 and yzang2019 October 10, 2025 20:15
}

func (b *RawBatch) Write() (err error) {
startTime := time.Now()
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be neater to pass this as argument to defer function. It gives it a tight scope at compile time.

// PebbleDB State Store Metrics
PebbleDBMetrics = struct {
// Operation Latencies
GetLatency metric.Int64Histogram
Copy link
Contributor

Choose a reason for hiding this comment

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

Adding the get latency might actually add too much overhead if each get would need to update the metric, I'd recommend let's remove this for perf concern.

Copy link
Contributor Author

@Kbhat1 Kbhat1 Oct 20, 2025

Choose a reason for hiding this comment

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

Discussed this and we will leave in for now until we leave in for now and observe perf impact later. So far on detached rpc node have not noticed perf impacts

@Kbhat1 Kbhat1 requested review from masih and yzang2019 October 20, 2025 20:32
Copy link
Collaborator

@masih masih left a comment

Choose a reason for hiding this comment

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

Please let me know if I can help expand on any of the comments. Thank you for adding all these metrics @Kbhat1 - they are a great investment in understanding the KV store performance 🍻

CommitLatency metric.Int64Histogram
ApplyChangesetLatency metric.Int64Histogram
CommitLatency metric.Float64Histogram
ApplyChangesetLatency metric.Float64Histogram
Copy link
Collaborator

Choose a reason for hiding this comment

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

Beyond the scope this PR, but all the fields of this struct also shouldn't be exported? Un-exporting the struct would limit the future scope creep and we can revisit this in a separate refactor PR if that's easier.

@Kbhat1 Kbhat1 requested a review from masih October 22, 2025 15:10
@Kbhat1
Copy link
Contributor Author

Kbhat1 commented Oct 22, 2025

@masih take a look again when you can

time.Since(startTime).Seconds(),
metric.WithAttributes(
attribute.Bool("success", _err == nil),
attribute.String("store", storeKey),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fyi @yzang2019 added attribute for storeKey for both Get and iteration

@github-actions
Copy link

github-actions bot commented Oct 22, 2025

The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedOct 24, 2025, 1:20 PM

}

func (b *Batch) Write() (err error) {
startTime := time.Now()

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism
}

func (b *RawBatch) Write() (err error) {
startTime := time.Now()

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism

func (db *Database) Get(storeKey string, targetVersion int64, key []byte) ([]byte, error) {
func (db *Database) Get(storeKey string, targetVersion int64, key []byte) (_ []byte, _err error) {
startTime := time.Now()

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism
// ApplyChangesetSync apply all changesets for a single version in blocking way
func (db *Database) ApplyChangesetSync(version int64, changeset []*proto.NamedChangeSet) error {
func (db *Database) ApplyChangesetSync(version int64, changeset []*proto.NamedChangeSet) (_err error) {
startTime := time.Now()

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism

func (db *Database) ApplyChangesetAsync(version int64, changesets []*proto.NamedChangeSet) error {
func (db *Database) ApplyChangesetAsync(version int64, changesets []*proto.NamedChangeSet) (_err error) {
startTime := time.Now()

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism

func (db *Database) computeHashForRange(beginBlock, endBlock int64) error {
func (db *Database) computeHashForRange(beginBlock, endBlock int64) (_err error) {
startTime := time.Now()

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism
// This is not a large issue given the next time that module is updated, it will be properly pruned thereafter.
func (db *Database) Prune(version int64) error {
func (db *Database) Prune(version int64) (_err error) {
startTime := time.Now()

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism
Copy link
Collaborator

@masih masih left a comment

Choose a reason for hiding this comment

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

One blocker on background metric collection context cancel function, and left some questions about cardinality just to double check they are not explosively large as they increase the number of metrics exponentially.

Thank you so much for addressing all the comments @Kbhat1, cannot wait to dig through the data being collected by the metrics 🚀

// Start background metrics collection
metricsCtx, metricsCancel := context.WithCancel(context.Background())
database.metricsCancel = metricsCancel
go database.collectMetricsInBackground(metricsCtx)

Check notice

Code scanning / CodeQL

Spawning a Go routine Note

Spawning a Go routine may be a possible source of non-determinism
@Kbhat1 Kbhat1 requested a review from masih October 23, 2025 16:29
@Kbhat1 Kbhat1 enabled auto-merge (squash) October 24, 2025 13:20
@Kbhat1 Kbhat1 merged commit a697f8e into main Oct 24, 2025
94 of 96 checks passed
@Kbhat1 Kbhat1 deleted the SSMetricsPebble branch October 24, 2025 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants