Skip to content

Commit 0952817

Browse files
craig[bot]mgartnerpav-kv
committed
143305: util/mon: reduce monitor-related allocations r=mgartner a=mgartner #### util/mon: rename fields of MonitorName Release note: None #### util/uuid: add comment to uuid.Short Release note: None #### util/mon: add fields to MonitorName The `processorID`, `suffix`, and `i` fields will be used in future commits to reduce allocations related to MonitorNames. Release note: None #### util/mon: compile-time checks for size of BytesMonitor and BoundAccount Release note: None #### sql: use mon.MonitorName in more places Using structured `mon.MonitorName` objects reduces allocations of strings in some cases. This commit doesn't replace all usages of string monitor names - there are myriad such usages. We can iteratively chip away at them in future commits. Release note: None #### util/mon: reduce size of MonitorName The size of `MonitorName` has been reduced by replacing the string suffix with a suffix enum. Release note: None #### util/mon: further reduce the size of MonitorName The size of `MonitorName` has been reduced by using the same 4 bytes to store either the `int32` processor ID or the `uuid.Short`, and by reducing the optional integer suffix from an `int32` to `uint16`, which should be sufficient in all cases. Release note: None #### util/mon: rename MonitorName to Name Release note: None #### util/mon: remove deprecated NewMonitorWithStringName All usages of the deprecated NewMonitorWithStringName function have been replaced with NewMonitor, and the former has been removed. Release note: None #### util/mon: remove deprecated NewMonitorInheritWithLimitAndStringName All usages of the deprecated NewMonitorInheritWithLimitAndStringName function have been replaced with NewMonitorInheritWithLimit, and the former has been removed. Release note: None #### colexec: batch allocations of BoundAccount Allocations of `BoundAccount`s in `createUnlimitedMemAccountsLocked` are now batched into a single allocation. Release note: None #### sql/rowflow: refactor monitor name The monitor names created in `(*rowBasedFlow).setupRouter` now use `(*mon.Name).WithID` to add the stream ID to the name instead of allocating a new string. Epic: None Release note: None 143390: raft: remove sync writes API r=tbg a=pav-kv This PR removes the synchronous writes API from raft. All storage interaction is done via the asynchronous API, which used to be guarded by the `AsyncStorageWrites` config option. Further work will double down on the asynchronous API and make it type-safe. Resolves #129411 Part of #124440 Co-authored-by: Marcus Gartner <[email protected]> Co-authored-by: Pavel Kalinnikov <[email protected]>
3 parents 1211500 + 7ae775f + 36834ab commit 0952817

File tree

112 files changed

+578
-419
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+578
-419
lines changed

pkg/backup/backup_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8370,7 +8370,7 @@ func TestReadBackupManifestMemoryMonitoring(t *testing.T) {
83708370
require.NoError(t, err)
83718371

83728372
m := mon.NewMonitor(mon.Options{
8373-
Name: mon.MakeMonitorName("test-monitor"),
8373+
Name: mon.MakeName("test-monitor"),
83748374
Settings: st,
83758375
})
83768376
m.Start(ctx, nil, mon.NewStandaloneBudget(128<<20))

pkg/backup/backuputils/memory_backed_quota_pool.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func NewMemoryBackedQuotaPool(
4040
}
4141

4242
if m != nil {
43-
q.mon = mon.NewMonitorInheritWithLimit(name, limit, m, false /* longLiving */)
43+
q.mon = mon.NewMonitorInheritWithLimit(mon.MakeName(name), limit, m, false /* longLiving */)
4444
q.mon.StartNoReserved(ctx, m)
4545
mem := q.mon.MakeBoundAccount()
4646
q.mem = &mem

pkg/backup/backuputils/memory_backed_quota_pool_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121

2222
func getMemoryMonitor(limit int64) *mon.BytesMonitor {
2323
return mon.NewMonitor(mon.Options{
24-
Name: mon.MakeMonitorName("test-mon"),
24+
Name: mon.MakeName("test-mon"),
2525
Limit: limit,
2626
Increment: 1,
2727
Settings: cluster.MakeTestingClusterSettings(),

pkg/backup/restore_data_processor_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ func runTestIngest(t *testing.T, init func(*cluster.Settings)) {
270270
Settings: s.ClusterSettings(),
271271
Codec: s.Codec(),
272272
BackupMonitor: mon.NewUnlimitedMonitor(ctx, mon.Options{
273-
Name: mon.MakeMonitorName("test"),
273+
Name: mon.MakeName("test"),
274274
Settings: s.ClusterSettings(),
275275
}),
276276
BulkSenderLimiter: limit.MakeConcurrentRequestLimiter("test", math.MaxInt),

pkg/base/config.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -947,11 +947,11 @@ func InheritTempStorageConfig(
947947
func newTempStorageConfig(
948948
ctx context.Context, st *cluster.Settings, inMemory bool, useStore StoreSpec, maxSizeBytes int64,
949949
) TempStorageConfig {
950-
var monitorName mon.MonitorName
950+
var monitorName mon.Name
951951
if inMemory {
952-
monitorName = mon.MakeMonitorName("in-mem temp storage")
952+
monitorName = mon.MakeName("in-mem temp storage")
953953
} else {
954-
monitorName = mon.MakeMonitorName("temp disk storage")
954+
monitorName = mon.MakeName("temp disk storage")
955955
}
956956
monitor := mon.NewMonitor(mon.Options{
957957
Name: monitorName,

pkg/base/test_server_args.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ func DefaultTestTempStorageConfigWithSize(
591591
st *cluster.Settings, maxSizeBytes int64,
592592
) TempStorageConfig {
593593
monitor := mon.NewMonitor(mon.Options{
594-
Name: mon.MakeMonitorName("in-mem temp storage"),
594+
Name: mon.MakeName("in-mem temp storage"),
595595
Res: mon.DiskResource,
596596
Increment: 1024 * 1024,
597597
Settings: st,

pkg/ccl/changefeedccl/changefeed_processors.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ func newChangeAggregatorProcessor(
195195
}
196196
}()
197197

198-
memMonitor := execinfra.NewMonitor(ctx, flowCtx.Mon, "changeagg-mem")
198+
memMonitor := execinfra.NewMonitor(ctx, flowCtx.Mon, mon.MakeName("changeagg-mem"))
199199
ca := &changeAggregator{
200200
spec: spec,
201201
memAcc: memMonitor.MakeBoundAccount(),
@@ -444,7 +444,7 @@ func (ca *changeAggregator) startKVFeed(
444444
opts changefeedbase.StatementOptions,
445445
) (kvevent.Reader, chan struct{}, chan error, error) {
446446
cfg := ca.FlowCtx.Cfg
447-
kvFeedMemMon := mon.NewMonitorInheritWithLimit("kvFeed", memLimit, parentMemMon, false /* longLiving */)
447+
kvFeedMemMon := mon.NewMonitorInheritWithLimit(mon.MakeName("kvFeed"), memLimit, parentMemMon, false /* longLiving */)
448448
kvFeedMemMon.StartNoReserved(ctx, parentMemMon)
449449
buf := kvevent.NewThrottlingBuffer(
450450
kvevent.NewMemBuffer(kvFeedMemMon.MakeBoundAccount(), &cfg.Settings.SV, &ca.metrics.KVFeedMetrics.AggregatorBufferMetricsWithCompat),
@@ -1193,7 +1193,7 @@ func newChangeFrontierProcessor(
11931193
input execinfra.RowSource,
11941194
post *execinfrapb.PostProcessSpec,
11951195
) (execinfra.Processor, error) {
1196-
memMonitor := execinfra.NewMonitor(ctx, flowCtx.Mon, "changefntr-mem")
1196+
memMonitor := execinfra.NewMonitor(ctx, flowCtx.Mon, mon.MakeName("changefntr-mem"))
11971197

11981198
cf := &changeFrontier{
11991199
// We might modify the ChangefeedState field in the eval.Context, so we

pkg/ccl/changefeedccl/changefeed_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9330,7 +9330,7 @@ func TestChangefeedPredicateWithSchemaChange(t *testing.T) {
93309330

93319331
func startMonitorWithBudget(budget int64) *mon.BytesMonitor {
93329332
mm := mon.NewMonitor(mon.Options{
9333-
Name: mon.MakeMonitorName("test-mm"),
9333+
Name: mon.MakeName("test-mm"),
93349334
Limit: budget,
93359335
Increment: 128, /* small allocation increment */
93369336
Settings: cluster.MakeTestingClusterSettings(),

pkg/ccl/changefeedccl/kvevent/blocking_buffer_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func makeRangeFeedEvent(rnd *rand.Rand, valSize int, prevValSize int) *kvpb.Rang
6868

6969
func getBoundAccountWithBudget(budget int64) (account mon.BoundAccount, cleanup func()) {
7070
mm := mon.NewMonitor(mon.Options{
71-
Name: mon.MakeMonitorName("test-mm"),
71+
Name: mon.MakeName("test-mm"),
7272
Limit: budget,
7373
Increment: 128, /* small allocation increment */
7474
Settings: cluster.MakeTestingClusterSettings(),

pkg/ccl/changefeedccl/kvfeed/kv_feed_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func TestKVFeed(t *testing.T) {
120120
runTest := func(t *testing.T, tc testCase) {
121121
settings := cluster.MakeTestingClusterSettings()
122122
mm := mon.NewUnlimitedMonitor(context.Background(), mon.Options{
123-
Name: mon.MakeMonitorName("test"),
123+
Name: mon.MakeName("test"),
124124
Settings: settings,
125125
})
126126
metrics := kvevent.MakeMetrics(time.Minute)

0 commit comments

Comments
 (0)