Skip to content

Commit

Permalink
kvserver: add metrics for when read-only batches drop latches
Browse files Browse the repository at this point in the history
Release note: None
  • Loading branch information
aayushshah15 committed Nov 17, 2022
1 parent 7ff05f1 commit 52a0e00
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
19 changes: 18 additions & 1 deletion pkg/kv/kvserver/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -1651,7 +1651,6 @@ Note that the measurement does not include the duration for replicating the eval
Measurement: "Nanoseconds",
Unit: metric.Unit_NANOSECONDS,
}

metaPopularKeyCount = metric.Metadata{
Name: "kv.loadsplitter.popularkey",
Help: "Load-based splitter could not find a split key and the most popular sampled split key occurs in >= 25% of the samples.",
Expand Down Expand Up @@ -1679,6 +1678,18 @@ Note that the measurement does not include the duration for replicating the eval
Measurement: "Fsync Latency",
Unit: metric.Unit_NANOSECONDS,
}
metaReplicaReadBatchDroppedLatchesBeforeEval = metric.Metadata{
Name: "kv.replica_read_batch_evaluate.dropped_latches_before_eval",
Help: `Number of times read-only batches dropped latches before evaluation.`,
Measurement: "Batches",
Unit: metric.Unit_COUNT,
}
metaReplicaReadBatchWithoutInterleavingIter = metric.Metadata{
Name: "kv.replica_read_batch_evaluate.without_interleaving_iter",
Help: `Number of read-only batches evaluated without an intent interleaving iter.`,
Measurement: "Batches",
Unit: metric.Unit_COUNT,
}
)

// StoreMetrics is the set of metrics for a given store.
Expand Down Expand Up @@ -1975,6 +1986,9 @@ type StoreMetrics struct {
ReplicaReadBatchEvaluationLatency *metric.Histogram
ReplicaWriteBatchEvaluationLatency *metric.Histogram

ReplicaReadBatchDroppedLatchesBeforeEval *metric.Counter
ReplicaReadBatchWithoutInterleavingIter *metric.Counter

FlushUtilization *metric.GaugeFloat64
FsyncLatency *metric.ManualWindowHistogram
}
Expand Down Expand Up @@ -2517,6 +2531,9 @@ func newStoreMetrics(histogramWindow time.Duration) *StoreMetrics {
),
FlushUtilization: metric.NewGaugeFloat64(metaStorageFlushUtilization),
FsyncLatency: metric.NewManualWindowHistogram(metaStorageFsyncLatency, pebble.FsyncLatencyBuckets),

ReplicaReadBatchDroppedLatchesBeforeEval: metric.NewCounter(metaReplicaReadBatchDroppedLatchesBeforeEval),
ReplicaReadBatchWithoutInterleavingIter: metric.NewCounter(metaReplicaReadBatchWithoutInterleavingIter),
}

{
Expand Down
2 changes: 2 additions & 0 deletions pkg/kv/kvserver/replica_read.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ func (r *Replica) executeReadOnlyBatch(
// the request is not being optimistically evaluated (optimistic evaluation
// does not wait for latches or check locks).
log.VEventf(ctx, 3, "lock table scan complete without conflicts; dropping latches early")
r.store.metrics.ReplicaReadBatchDroppedLatchesBeforeEval.Inc(1)
if !stillNeedsInterleavedIntents {
r.store.metrics.ReplicaReadBatchWithoutInterleavingIter.Inc(1)
evalPath = readOnlyWithoutInterleavedIntents
}
r.updateTimestampCacheAndDropLatches(ctx, g, ba, nil /* br */, nil /* pErr */, st)
Expand Down
12 changes: 12 additions & 0 deletions pkg/ts/catalog/chart_catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -3750,4 +3750,16 @@ var charts = []sectionDescription{
},
},
},
{
Organization: [][]string{{ReplicationLayer, "Batches"}},
Charts: []chartDescription{
{
Title: "Total number of attempts to evaluate read-only batches",
Metrics: []string{
"kv.replica_read_batch_evaluate.dropped_latches_before_eval",
"kv.replica_read_batch_evaluate.without_interleaving_iter",
},
},
},
},
}

0 comments on commit 52a0e00

Please sign in to comment.