Skip to content

Commit a22372d

Browse files
craig[bot]jordanlewisknzRaduBerinde
committed
29077: backport-2.1: storage,kv: remove some allocations r=jordanlewis a=jordanlewis Backport 1/1 commits from #29075. /cc @cockroachdb/release --- Guard an expensive log.V in a log.ExpensiveLogEnabled. Pass roachpb.Lease by value in one situation in which allocating it is pointless. cc @benesch This seems to improve read-only kv performance by almost 5%! Release note: None 29103: release-2.1: base: make TestValidateAddrs portable r=knz a=knz Backport 1/1 commits from #29101. /cc @cockroachdb/release --- On (at least) osx the port name resolution error is different. This patch modifies the test to catch that. Release note: None 29121: release-2.1: opt: fix LookupJoinDef interning, add tests r=RaduBerinde a=RaduBerinde Backport 1/1 commits from #29117. /cc @cockroachdb/release --- Fixing an omission I noticed in internLookupJoinDef and adding missing tests for interning defs. Release note: None Co-authored-by: Jordan Lewis <[email protected]> Co-authored-by: Raphael 'kena' Poss <[email protected]> Co-authored-by: Radu Berinde <[email protected]>
4 parents 0aec4a9 + 497feb7 + 6915d56 + c4bf79a commit a22372d

11 files changed

+396
-13
lines changed

pkg/base/addr_validation_test.go

+16-1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,21 @@ func TestValidateAddrs(t *testing.T) {
6060
localAddr = "[" + localAddr + "]"
6161
}
6262

63+
// We need to know what a port name resolution error look like,
64+
// because they may be different across systems/libcs.
65+
_, err = net.DefaultResolver.LookupPort(context.Background(), "tcp", "nonexistent")
66+
if err == nil {
67+
t.Fatal("expected port resolution failure, got no error")
68+
}
69+
portExpectedErr := err.Error()
70+
// For the host name resolution error we can reliably expect "no such host"
71+
// below, but before we test anything we need to ensure we indeed have
72+
// a reliably non-resolvable host name.
73+
_, err = net.DefaultResolver.LookupIPAddr(context.Background(), "nonexistent.example.com")
74+
if err == nil {
75+
t.Fatal("expected host resolution failure, got no error")
76+
}
77+
6378
// The test cases.
6479
testData := []struct {
6580
in addrs
@@ -120,7 +135,7 @@ func TestValidateAddrs(t *testing.T) {
120135
{addrs{":26257", "", "localhost", ""}, "invalid --http-addr.*missing port in address", addrs{}},
121136
// Invalid port number.
122137
{addrs{"localhost:-1231", "", "", ""}, "invalid port", addrs{}},
123-
{addrs{"localhost:nonexistent", "", "", ""}, "unknown port", addrs{}},
138+
{addrs{"localhost:nonexistent", "", "", ""}, portExpectedErr, addrs{}},
124139
// Invalid address.
125140
{addrs{"nonexistent.example.com:26257", "", "", ""}, "no such host", addrs{}},
126141
{addrs{"333.333.333.333:26257", "", "", ""}, "no such host", addrs{}},

pkg/kv/dist_sender.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -1279,7 +1279,9 @@ func (ds *DistSender) sendToReplicas(
12791279
}
12801280

12811281
curReplica := transport.NextReplica()
1282-
log.VEventf(ctx, 2, "r%d: sending batch %s to %s", rangeID, args.Summary(), curReplica)
1282+
if log.ExpensiveLogEnabled(ctx, 2) {
1283+
log.VEventf(ctx, 2, "r%d: sending batch %s to %s", rangeID, args.Summary(), curReplica)
1284+
}
12831285
br, err := transport.SendNext(ctx)
12841286

12851287
// This loop will retry operations that fail with errors that reflect

pkg/sql/opt/memo/private_storage.go

+2
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,9 @@ func (ps *privateStorage) internLookupJoinDef(def *LookupJoinDef) PrivateID {
315315
// The below code is carefully constructed to not allocate in the case where
316316
// the value is already in the map. Be careful when modifying.
317317
ps.keyBuf.Reset()
318+
ps.keyBuf.writeUvarint(uint64(def.JoinType))
318319
ps.keyBuf.writeUvarint(uint64(def.Table))
320+
ps.keyBuf.writeUvarint(uint64(def.Index))
319321
ps.keyBuf.writeColList(def.KeyCols)
320322
// Add a separator between the list and the set. Note that the column IDs
321323
// cannot be 0.

0 commit comments

Comments
 (0)