From 05cb78a95835cdeb76a872820829acac4b6c4ab5 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Thu, 31 Mar 2022 13:47:49 +0000 Subject: [PATCH] kv/bulk: add low priority admission header to bulk SSTs Release note (performance improvement): Bulk ingestion writes now use a lower priority for admission control. --- pkg/kv/bulk/BUILD.bazel | 1 + pkg/kv/bulk/sst_batcher.go | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/pkg/kv/bulk/BUILD.bazel b/pkg/kv/bulk/BUILD.bazel index 5a4e0d078b53..8c95ef58dfb4 100644 --- a/pkg/kv/bulk/BUILD.bazel +++ b/pkg/kv/bulk/BUILD.bazel @@ -22,6 +22,7 @@ go_library( "//pkg/settings/cluster", "//pkg/storage", "//pkg/storage/enginepb", + "//pkg/util/admission", "//pkg/util/hlc", "//pkg/util/humanizeutil", "//pkg/util/log", diff --git a/pkg/kv/bulk/sst_batcher.go b/pkg/kv/bulk/sst_batcher.go index e6e6611b4bcd..dc8fdad1290f 100644 --- a/pkg/kv/bulk/sst_batcher.go +++ b/pkg/kv/bulk/sst_batcher.go @@ -25,6 +25,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/settings/cluster" "github.com/cockroachdb/cockroach/pkg/storage" "github.com/cockroachdb/cockroach/pkg/storage/enginepb" + "github.com/cockroachdb/cockroach/pkg/util/admission" "github.com/cockroachdb/cockroach/pkg/util/hlc" "github.com/cockroachdb/cockroach/pkg/util/humanizeutil" "github.com/cockroachdb/cockroach/pkg/util/log" @@ -552,9 +553,16 @@ func (b *SSTBatcher) addSSTable( req.SSTTimestampToRequestTimestamp = b.batchTS } - ba := roachpb.BatchRequest{Header: roachpb.Header{Timestamp: b.batchTS}} + ba := roachpb.BatchRequest{ + Header: roachpb.Header{Timestamp: b.batchTS}, + AdmissionHeader: roachpb.AdmissionHeader{ + Priority: int32(admission.BulkNormalPri), + CreateTime: timeutil.Now().UnixNano(), + Source: roachpb.AdmissionHeader_FROM_SQL, + NoMemoryReservedAtSource: true, + }, + } ba.Add(req) - beforeSend := timeutil.Now() br, pErr := b.db.NonTransactionalSender().Send(ctx, ba) sendTime := timeutil.Since(beforeSend)