Skip to content

Commit cb41ba2

Browse files
craig[bot]suvaidkhanmiraradevaasg0451
committed
147879: buildutil.bzl: fix disallowed_imports_test logic and refactor BUILD.bazel r=rickystewart a=suvaidkhan Changes - - Changed `allowList` logic to check for empty list - Set `allowList` `disallowed_list` & `disallowed_prefixes` defaults to None and added None handling - If no list is passed in `disallowed_imports_test` an error is thrown - Refactored `disallowed_imports_test` in `pkg/server/diagnostics/BUILD.bazel`and `pkg/server/diagnostics/BUILD.bazel` Fixes #139892 148236: roachtest: add buffered-writes variants of TPCC bench r=stevendanna a=miraradeva This commit adds the following variants of TPCC bench: - write buffering enabled, pipelining enabled (by default), - write buffering enabled, pipelining disabled. The former will help us compare the performance of buffered writes to the default setup, and the latter will inform our decision to replace pipelining with buffering altogether. Part of: #148235 Release note: None 148302: changefeedccl: fix table drop shutdown for enriched envelope r=andyyang890 a=asg0451 Fixes a bug where feeds with enriched envelopes and a `source` field could treat table drops as transient errors. Fixes: #148216 Release note: None Co-authored-by: suvaidkhan <[email protected]> Co-authored-by: Mira Radeva <[email protected]> Co-authored-by: Miles Frankel <[email protected]>
4 parents e77b4be + d324ffb + b738ccd + fc128c7 commit cb41ba2

File tree

7 files changed

+128
-6
lines changed

7 files changed

+128
-6
lines changed

pkg/ccl/changefeedccl/enriched_source_provider.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,9 @@ func getDescriptors(
540540
return nil
541541
}
542542
if err := execCfg.InternalDB.DescsTxn(ctx, f, isql.WithPriority(admissionpb.NormalPri)); err != nil {
543+
if errors.Is(err, catalog.ErrDescriptorDropped) {
544+
err = changefeedbase.WithTerminalError(err)
545+
}
543546
return nil, nil, nil, err
544547
}
545548
return tableDescriptor, dbDescriptor, schemaDescriptor, nil

pkg/cmd/roachtest/registry/test_spec.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,12 @@ type TestSpec struct {
131131
// to epoch leases.
132132
Leases LeaseType
133133

134+
// WriteOptimization specifies what kind of write optimization to use.
135+
// Defaults to pipelining. This is currently used only in benchmark tests.
136+
// If used in a non-benchmark test, this setting will be overwritten to enable
137+
// pipelining and additionally, with 50% probability, buffering.
138+
WriteOptimization WriteOptimizationType
139+
134140
// SkipPostValidations is a bit-set of post-validations that should be skipped
135141
// after the test completes. This is useful for tests that are known to be
136142
// incompatible with some validations. By default, tests will run all
@@ -284,6 +290,35 @@ const (
284290
// The list does not contain aliases like "default" and "metamorphic".
285291
var LeaseTypes = []LeaseType{EpochLeases, ExpirationLeases, LeaderLeases}
286292

293+
// WriteOptimizationType specifies the type of write optimization to use.
294+
type WriteOptimizationType int
295+
296+
func (w WriteOptimizationType) String() string {
297+
switch w {
298+
case DefaultWriteOptimization:
299+
return "default"
300+
case Pipelining:
301+
return "pipelining"
302+
case Buffering:
303+
return "buffering"
304+
case PipeliningBuffering:
305+
return "pipelining-buffering"
306+
default:
307+
return fmt.Sprintf("writeoptimization-%d", w)
308+
}
309+
}
310+
311+
const (
312+
// DefaultWriteOptimization uses the default cluster settings.
313+
DefaultWriteOptimization = WriteOptimizationType(iota)
314+
// Pipelining uses write pipelining.
315+
Pipelining
316+
// Buffering uses client-side write buffering.
317+
Buffering
318+
// PipeliningBuffering uses both buffering and pipelining.
319+
PipeliningBuffering
320+
)
321+
287322
// CloudSet represents a set of clouds.
288323
//
289324
// Instances of CloudSet are immutable. The uninitialized (zero) value is not

pkg/cmd/roachtest/test_runner.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,22 @@ func (r *testRunner) runWorker(
933933
t.Fatalf("unknown lease type %s", leases)
934934
}
935935

936+
// Choose which write optimization to use. These are currently used only
937+
// in benchmark tests. For non-benchmark tests, write buffering will be
938+
// enabled metamorphically below.
939+
switch testSpec.WriteOptimization {
940+
case registry.DefaultWriteOptimization:
941+
case registry.Pipelining:
942+
c.clusterSettings["kv.transaction.write_pipelining.enabled"] = "true"
943+
c.clusterSettings["kv.transaction.write_buffering.enabled"] = "false"
944+
case registry.Buffering:
945+
c.clusterSettings["kv.transaction.write_buffering.enabled"] = "true"
946+
c.clusterSettings["kv.transaction.write_pipelining.enabled"] = "false"
947+
case registry.PipeliningBuffering:
948+
c.clusterSettings["kv.transaction.write_pipelining.enabled"] = "true"
949+
c.clusterSettings["kv.transaction.write_buffering.enabled"] = "true"
950+
}
951+
936952
// Apply metamorphic settings not explicitly defined by the test.
937953
// These settings should only be applied to non-benchmark tests.
938954
if !testSpec.Benchmark {

pkg/cmd/roachtest/tests/tpcc.go

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1619,6 +1619,50 @@ func registerTPCC(r registry.Registry) {
16191619
Clouds: registry.OnlyGCE,
16201620
Suites: registry.Suites(registry.Weekly),
16211621
})
1622+
1623+
// Buffered writes benchmarks. These are duplicates of variants above.
1624+
1625+
// A variant with only buffering enabled (pipelining disabled).
1626+
registerTPCCBenchSpec(
1627+
r, tpccBenchSpec{
1628+
Nodes: 3,
1629+
CPUs: 16,
1630+
1631+
LoadWarehousesGCE: 3500,
1632+
LoadWarehousesAWS: 3900,
1633+
LoadWarehousesAzure: 3900,
1634+
LoadWarehousesIBM: 3900,
1635+
EstimatedMaxGCE: 3100,
1636+
EstimatedMaxAWS: 3600,
1637+
EstimatedMaxAzure: 3600,
1638+
EstimatedMaxIBM: 3600,
1639+
WriteOptimization: registry.Buffering,
1640+
1641+
Clouds: registry.AllClouds,
1642+
Suites: registry.Suites(registry.Nightly),
1643+
},
1644+
)
1645+
1646+
// A variant with pipelining and buffering both enabled.
1647+
registerTPCCBenchSpec(
1648+
r, tpccBenchSpec{
1649+
Nodes: 3,
1650+
CPUs: 16,
1651+
1652+
LoadWarehousesGCE: 3500,
1653+
LoadWarehousesAWS: 3900,
1654+
LoadWarehousesAzure: 3900,
1655+
LoadWarehousesIBM: 3900,
1656+
EstimatedMaxGCE: 3100,
1657+
EstimatedMaxAWS: 3600,
1658+
EstimatedMaxAzure: 3600,
1659+
EstimatedMaxIBM: 3600,
1660+
WriteOptimization: registry.PipeliningBuffering,
1661+
1662+
Clouds: registry.AllClouds,
1663+
Suites: registry.Suites(registry.Nightly),
1664+
},
1665+
)
16221666
}
16231667

16241668
func valueForCloud(cloud spec.Cloud, gce, aws, azure, ibm int) int {
@@ -1730,6 +1774,9 @@ type tpccBenchSpec struct {
17301774
// SharedProcessMT, if true, indicates that the cluster should run in
17311775
// shared-process mode of multi-tenancy.
17321776
SharedProcessMT bool
1777+
// WriteOptimization specifies the write optimization to use (e.g. pipelining,
1778+
// buffering, or both).
1779+
WriteOptimization registry.WriteOptimizationType
17331780
}
17341781

17351782
func (s tpccBenchSpec) EstimatedMax(cloud spec.Cloud) int {
@@ -1829,6 +1876,10 @@ func registerTPCCBenchSpec(r registry.Registry, b tpccBenchSpec) {
18291876
nameParts = append(nameParts, "mt-shared-process")
18301877
}
18311878

1879+
if b.WriteOptimization != registry.DefaultWriteOptimization {
1880+
nameParts = append(nameParts, fmt.Sprintf("write-optimization=%s", b.WriteOptimization.String()))
1881+
}
1882+
18321883
name := strings.Join(nameParts, "/")
18331884

18341885
numNodes := b.Nodes + b.LoadConfig.numLoadNodes(b.Distribution)
@@ -1844,6 +1895,7 @@ func registerTPCCBenchSpec(r registry.Registry, b tpccBenchSpec) {
18441895
Suites: b.Suites,
18451896
EncryptionSupport: encryptionSupport,
18461897
Leases: leases,
1898+
WriteOptimization: b.WriteOptimization,
18471899
PostProcessPerfMetrics: getMaxWarehousesAboveEfficiency,
18481900
Run: func(ctx context.Context, t test.Test, c cluster.Cluster) {
18491901
runTPCCBench(ctx, t, c, b)

pkg/roachpb/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,4 +163,5 @@ stringer(
163163
disallowed_imports_test(
164164
"roachpb",
165165
disallow_cdeps = True,
166+
disallowed_list = [],
166167
)

pkg/server/diagnostics/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,5 @@ disallowed_imports_test(
8787
"diagnostics",
8888
# TODO(#81378): This should be flipped to "true".
8989
disallow_cdeps = False,
90+
disallowed_list = [],
9091
)

pkg/testutils/buildutil/buildutil.bzl

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ _deps_aspect = aspect(
4949
)
5050

5151
def _find_deps_with_disallowed_prefixes(current_pkg, dep_pkgs, prefixes):
52+
if prefixes == None:
53+
return []
5254
return [dp for dp_list in [
5355
[(d, p) for p in prefixes if d.startswith(p) and d != current_pkg]
5456
for d in dep_pkgs
@@ -61,11 +63,13 @@ def _deps_rule_impl(ctx):
6163
prefixes = ctx.attr.disallowed_prefixes,
6264
)
6365
deps = {k: None for k in ctx.attr.src[_DepsInfo].deps.to_list()}
64-
if ctx.attr.allowlist:
66+
if ctx.attr.has_allowlist:
6567
failed = [p for p in deps if p not in ctx.attr.allowlist and
6668
p.label != ctx.attr.src.label]
67-
else:
69+
elif ctx.attr.has_disallowed_list:
6870
failed = [p for p in ctx.attr.disallowed_list if p in deps]
71+
else:
72+
failed = []
6973
failures = []
7074
if failed_prefixes:
7175
failures.extend([
@@ -108,10 +112,14 @@ _deps_rule = rule(
108112
"disallow_cdeps": attr.bool(mandatory = False, default = False),
109113
"disallowed_list": attr.label_list(providers = [GoInfo]),
110114
"disallowed_prefixes": attr.string_list(mandatory = False, allow_empty = True),
115+
"has_allowlist": attr.bool(default = False),
116+
"has_disallowed_list": attr.bool(default = False),
111117
},
112118
)
113119

114120
def _validate_disallowed_prefixes(prefixes):
121+
if prefixes == None:
122+
return []
115123
validated = []
116124
repo_prefix = "github.com/cockroachdb/cockroach/"
117125
short_prefix = "pkg/"
@@ -130,11 +138,15 @@ def _validate_disallowed_prefixes(prefixes):
130138

131139
def disallowed_imports_test(
132140
src,
133-
disallowed_list = [],
134-
disallowed_prefixes = [],
141+
disallowed_list = None,
142+
disallowed_prefixes = None,
135143
disallow_cdeps = False,
136-
allowlist = []):
137-
if (disallowed_list and allowlist) or (disallowed_prefixes and allowlist):
144+
allowlist = None):
145+
146+
if allowlist == None and disallowed_list == None and disallowed_prefixes == None:
147+
fail("Either allowlist, disallowed_list or disallowed_prefixes should be passed, to block " +
148+
"all imports you must explicitly pass allowlist = []")
149+
if (allowlist != None and disallowed_list != None) or (allowlist != None and disallowed_prefixes != None):
138150
fail("allowlist or (disallowed_list or disallowed_prefixes) can be " +
139151
"provided, but not both")
140152
disallowed_prefixes = _validate_disallowed_prefixes(disallowed_prefixes)
@@ -147,6 +159,8 @@ def disallowed_imports_test(
147159
disallowed_list = disallowed_list,
148160
disallowed_prefixes = disallowed_prefixes,
149161
disallow_cdeps = disallow_cdeps,
162+
has_allowlist = allowlist != None,
163+
has_disallowed_list = disallowed_list != None,
150164
)
151165
native.sh_test(
152166
name = src.strip(":") + "_disallowed_imports_test",

0 commit comments

Comments
 (0)