Skip to content

Commit a88367d

Browse files
craig[bot]kvoli
andcommitted
Merge #78995
78995: release-22.1: kvserver: gossip l0sublevels instead of read amp r=kvoli a=blathers-crl[bot] Backport 1/1 commits from #78949 on behalf of `@kvoli.` /cc `@cockroachdb/release` ---- Previously read amplification was gossipped among stores to enable future allocation decisions that would avoid candidates with high read amplification. L0 Sublevels represents the number of levels with L0 and is a portion of read amplification. This patch change read amplification to l0 sublevels, as it is a better indicator of store health. Release justification: low risk, replace deprecated gossip signal. Release note: None ---- Release justification: Co-authored-by: Austen McClernon <austen@cockroachlabs.com>
2 parents e7c27de + aee773a commit a88367d

5 files changed

Lines changed: 30 additions & 35 deletions

File tree

pkg/kv/kvserver/store.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2966,7 +2966,7 @@ func (s *Store) Capacity(ctx context.Context, useCached bool) (roachpb.StoreCapa
29662966
capacity.LogicalBytes = logicalBytes
29672967
capacity.QueriesPerSecond = totalQueriesPerSecond
29682968
capacity.WritesPerSecond = totalWritesPerSecond
2969-
capacity.ReadAmplification = s.metrics.RdbReadAmplification.Value()
2969+
capacity.L0Sublevels = s.metrics.RdbL0Sublevels.Value()
29702970
capacity.BytesPerReplica = roachpb.PercentilesFromData(bytesPerReplica)
29712971
capacity.WritesPerReplica = roachpb.PercentilesFromData(writesPerReplica)
29722972
s.recordNewPerSecondStats(totalQueriesPerSecond, totalWritesPerSecond)

pkg/kv/kvserver/store_pool.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -755,10 +755,6 @@ type StoreList struct {
755755
// candidateWritesPerSecond tracks writes-per-second stats for stores that are
756756
// eligible to be rebalance targets.
757757
candidateWritesPerSecond stat
758-
759-
// candidateReadAmplification tracks the read amplification stats for stores that are
760-
// eligible to be rebalance targets.
761-
candidateReadAmplification stat
762758
}
763759

764760
// Generates a new store list based on the passed in descriptors. It will
@@ -773,32 +769,30 @@ func makeStoreList(descriptors []roachpb.StoreDescriptor) StoreList {
773769
sl.candidateLogicalBytes.update(float64(desc.Capacity.LogicalBytes))
774770
sl.candidateQueriesPerSecond.update(desc.Capacity.QueriesPerSecond)
775771
sl.candidateWritesPerSecond.update(desc.Capacity.WritesPerSecond)
776-
sl.candidateReadAmplification.update(float64(desc.Capacity.ReadAmplification))
777772
}
778773
return sl
779774
}
780775

781776
func (sl StoreList) String() string {
782777
var buf bytes.Buffer
783778
fmt.Fprintf(&buf,
784-
" candidate: avg-ranges=%v avg-leases=%v avg-disk-usage=%v avg-queries-per-second=%v read-amplification=%v",
779+
" candidate: avg-ranges=%v avg-leases=%v avg-disk-usage=%v avg-queries-per-second=%v",
785780
sl.candidateRanges.mean,
786781
sl.candidateLeases.mean,
787782
humanizeutil.IBytes(int64(sl.candidateLogicalBytes.mean)),
788783
sl.candidateQueriesPerSecond.mean,
789-
sl.candidateReadAmplification.mean,
790784
)
791785
if len(sl.stores) > 0 {
792786
fmt.Fprintf(&buf, "\n")
793787
} else {
794788
fmt.Fprintf(&buf, " <no candidates>")
795789
}
796790
for _, desc := range sl.stores {
797-
fmt.Fprintf(&buf, " %d: ranges=%d leases=%d disk-usage=%s queries-per-second=%.2f read-amplification=%d\n",
791+
fmt.Fprintf(&buf, " %d: ranges=%d leases=%d disk-usage=%s queries-per-second=%.2f l0-sublevels=%d\n",
798792
desc.StoreID, desc.Capacity.RangeCount,
799793
desc.Capacity.LeaseCount, humanizeutil.IBytes(desc.Capacity.LogicalBytes),
800794
desc.Capacity.QueriesPerSecond,
801-
desc.Capacity.ReadAmplification,
795+
desc.Capacity.L0Sublevels,
802796
)
803797
}
804798
return buf.String()

pkg/kv/kvserver/store_pool_test.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -513,28 +513,28 @@ func TestStorePoolUpdateLocalStore(t *testing.T) {
513513
StoreID: 1,
514514
Node: roachpb.NodeDescriptor{NodeID: 1},
515515
Capacity: roachpb.StoreCapacity{
516-
Capacity: 100,
517-
Available: 50,
518-
RangeCount: 5,
519-
LeaseCount: 1,
520-
LogicalBytes: 30,
521-
QueriesPerSecond: 100,
522-
WritesPerSecond: 30,
523-
ReadAmplification: 5,
516+
Capacity: 100,
517+
Available: 50,
518+
RangeCount: 5,
519+
LeaseCount: 1,
520+
LogicalBytes: 30,
521+
QueriesPerSecond: 100,
522+
WritesPerSecond: 30,
523+
L0Sublevels: 4,
524524
},
525525
},
526526
{
527527
StoreID: 2,
528528
Node: roachpb.NodeDescriptor{NodeID: 2},
529529
Capacity: roachpb.StoreCapacity{
530-
Capacity: 100,
531-
Available: 55,
532-
RangeCount: 4,
533-
LeaseCount: 2,
534-
LogicalBytes: 25,
535-
QueriesPerSecond: 50,
536-
WritesPerSecond: 25,
537-
ReadAmplification: 10,
530+
Capacity: 100,
531+
Available: 55,
532+
RangeCount: 4,
533+
LeaseCount: 2,
534+
LogicalBytes: 25,
535+
QueriesPerSecond: 50,
536+
WritesPerSecond: 25,
537+
L0Sublevels: 8,
538538
},
539539
},
540540
}
@@ -576,8 +576,8 @@ func TestStorePoolUpdateLocalStore(t *testing.T) {
576576
if expectedWPS := 30 + WPS; desc.Capacity.WritesPerSecond != expectedWPS {
577577
t.Errorf("expected WritesPerSecond %f, but got %f", expectedWPS, desc.Capacity.WritesPerSecond)
578578
}
579-
if expectedReadAmp := int64(5); desc.Capacity.ReadAmplification != expectedReadAmp {
580-
t.Errorf("expected ReadAmplification %d, but got %d", expectedReadAmp, desc.Capacity.ReadAmplification)
579+
if expectedL0Sublevels := int64(4); desc.Capacity.L0Sublevels != expectedL0Sublevels {
580+
t.Errorf("expected L0 Sub-Levels %d, but got %d", expectedL0Sublevels, desc.Capacity.L0Sublevels)
581581
}
582582

583583
sp.updateLocalStoreAfterRebalance(roachpb.StoreID(2), rangeUsageInfo, roachpb.REMOVE_VOTER)
@@ -597,8 +597,8 @@ func TestStorePoolUpdateLocalStore(t *testing.T) {
597597
if expectedWPS := 25 - WPS; desc.Capacity.WritesPerSecond != expectedWPS {
598598
t.Errorf("expected WritesPerSecond %f, but got %f", expectedWPS, desc.Capacity.WritesPerSecond)
599599
}
600-
if expectedReadAmp := int64(10); desc.Capacity.ReadAmplification != expectedReadAmp {
601-
t.Errorf("expected ReadAmplification %d, but got %d", expectedReadAmp, desc.Capacity.ReadAmplification)
600+
if expectedL0Sublevels := int64(8); desc.Capacity.L0Sublevels != expectedL0Sublevels {
601+
t.Errorf("expected L0 Sub-Levels %d, but got %d", expectedL0Sublevels, desc.Capacity.L0Sublevels)
602602
}
603603

604604
sp.updateLocalStoresAfterLeaseTransfer(roachpb.StoreID(1), roachpb.StoreID(2), rangeUsageInfo.QueriesPerSecond)

pkg/roachpb/metadata.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -570,12 +570,12 @@ func (sc StoreCapacity) String() string {
570570
// SafeFormat implements the redact.SafeFormatter interface.
571571
func (sc StoreCapacity) SafeFormat(w redact.SafePrinter, _ rune) {
572572
w.Printf("disk (capacity=%s, available=%s, used=%s, logicalBytes=%s), "+
573-
"ranges=%d, leases=%d, queries=%.2f, writes=%.2f, readAmplification=%d"+
574-
"bytesPerReplica={%s}, writesPerReplica={%s}",
573+
"ranges=%d, leases=%d, queries=%.2f, writes=%.2f, "+
574+
"l0Sublevels=%d, bytesPerReplica={%s}, writesPerReplica={%s}",
575575
humanizeutil.IBytes(sc.Capacity), humanizeutil.IBytes(sc.Available),
576576
humanizeutil.IBytes(sc.Used), humanizeutil.IBytes(sc.LogicalBytes),
577577
sc.RangeCount, sc.LeaseCount, sc.QueriesPerSecond, sc.WritesPerSecond,
578-
sc.ReadAmplification, sc.BytesPerReplica, sc.WritesPerReplica)
578+
sc.L0Sublevels, sc.BytesPerReplica, sc.WritesPerReplica)
579579
}
580580

581581
// FractionUsed computes the fraction of storage capacity that is in use.

pkg/roachpb/metadata.proto

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,16 +330,17 @@ message StoreCapacity {
330330
// by ranges in the store. The stat is tracked over the time period defined
331331
// in storage/replica_stats.go, which as of July 2018 is 30 minutes.
332332
optional double writes_per_second = 5 [(gogoproto.nullable) = false];
333-
// read_amplification tracks the current read amplification in the store.
333+
// l0_sublevels tracks the current number of l0 sublevels in the store.
334334
// TODO(kvoli): Use of this field will need to be version-gated, to avoid
335335
// instances where overlapping node-binary versions within a cluster result
336336
// in this this field missing.
337-
optional int64 read_amplification = 11 [(gogoproto.nullable) = false];
337+
optional int64 l0_sublevels = 12 [(gogoproto.nullable) = false];
338338
// bytes_per_replica and writes_per_replica contain percentiles for the
339339
// number of bytes and writes-per-second to each replica in the store.
340340
// This information can be used for rebalancing decisions.
341341
optional Percentiles bytes_per_replica = 6 [(gogoproto.nullable) = false];
342342
optional Percentiles writes_per_replica = 7 [(gogoproto.nullable) = false];
343+
reserved 11;
343344
}
344345

345346
// StoreProperties contains configuration and OS-level details for a storage device.

0 commit comments

Comments
 (0)