forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
admission,kvserver: broadcast per-store IO overload status
The plan for cockroachdb#79215 is to have stores not send to followers that are experiencing IO overload, unless this is necessary for quorum. This commit teaches admission control to relay the current status of the IO overload signals to the Store, which in turn gossips it. We add a type `IOThreshold` that encapsulates the input signals to I/O admission control to present them as a unified score, which hopefully leads to less ad-hoc use of the underlying signals. Together, this paves the way for using the signal to inform distribution decisions (cockroachdb#83490) and (bluntly) shape raft traffic (cockroachdb#79215). Touches cockroachdb#79215. Touches cockroachdb#77604. Touches cockroachdb#82611. Touches cockroachdb#83490. Release note: None
- Loading branch information
Showing
14 changed files
with
213 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,36 @@ | ||
load("@rules_proto//proto:defs.bzl", "proto_library") | ||
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") | ||
load("@io_bazel_rules_go//go:def.bzl", "go_library") | ||
|
||
go_library( | ||
name = "admissionpb", | ||
srcs = [ | ||
"admissionpb.go", | ||
"doc.go", | ||
"io_threshold.go", | ||
], | ||
embed = [":admissionpb_go_proto"], | ||
importpath = "github.com/cockroachdb/cockroach/pkg/util/admission/admissionpb", | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"@com_github_cockroachdb_redact//:redact", | ||
"@com_github_cockroachdb_redact//interfaces", | ||
], | ||
) | ||
|
||
proto_library( | ||
name = "admissionpb_proto", | ||
srcs = ["io_threshold.proto"], | ||
strip_import_prefix = "/pkg", | ||
visibility = ["//visibility:public"], | ||
deps = ["@com_github_gogo_protobuf//gogoproto:gogo_proto"], | ||
) | ||
|
||
go_proto_library( | ||
name = "admissionpb_go_proto", | ||
compilers = ["//pkg/cmd/protoc-gen-gogoroach:protoc-gen-gogoroach_compiler"], | ||
importpath = "github.com/cockroachdb/cockroach/pkg/util/admission/admissionpb", | ||
proto = ":admissionpb_proto", | ||
visibility = ["//visibility:public"], | ||
deps = ["@com_github_gogo_protobuf//gogoproto"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright 2022 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
// | ||
|
||
package admissionpb | ||
|
||
import ( | ||
"math" | ||
|
||
"github.com/cockroachdb/redact" | ||
"github.com/cockroachdb/redact/interfaces" | ||
) | ||
|
||
// Score returns, as the second return value, whether IO admission control is | ||
// considering the Store overloaded. The first return value is a 1-normalized | ||
// float (i.e. 1.0 is the threshold at which the second value flips to true). | ||
// | ||
// The zero value returns (0, false). Use of the nil pointer is not allowed. | ||
func (iot IOThreshold) Score() (float64, bool) { | ||
if iot == (IOThreshold{}) { | ||
return 0, false | ||
} | ||
f := math.Max( | ||
float64(iot.L0NumFiles)/float64(iot.L0NumFilesThreshold), | ||
float64(iot.L0NumSubLevels)/float64(iot.L0NumSubLevelsThreshold), | ||
) | ||
return f, f > 1.0 | ||
} | ||
|
||
// SafeFormat implements redact.SafeFormatter. | ||
func (iot IOThreshold) SafeFormat(s interfaces.SafePrinter, _ rune) { | ||
if iot == (IOThreshold{}) { | ||
s.Printf("N/A") | ||
} | ||
sc, overload := iot.Score() | ||
s.Printf("%.3f", redact.SafeFloat(sc)) | ||
if overload { | ||
s.Printf("[overload]") | ||
} | ||
} | ||
|
||
func (iot IOThreshold) String() string { | ||
return redact.StringWithoutMarkers(iot) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright 2022 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
syntax = "proto3"; | ||
package cockroach.util.admission.admissionpb; | ||
option go_package = "admissionpb"; | ||
|
||
import "gogoproto/gogo.proto"; | ||
|
||
// IOThreshold wraps the raw signals that IO admission control utilizes to determine | ||
// when to introduce queueing. | ||
message IOThreshold { | ||
option (gogoproto.goproto_stringer) = false; | ||
|
||
int64 l0_num_sub_levels = 1; | ||
int64 l0_num_sub_levels_threshold = 2; | ||
int64 l0_num_files = 3; | ||
int64 l0_num_files_threshold = 4; | ||
} |
Oops, something went wrong.