|
9 | 9 | "context"
|
10 | 10 | "time"
|
11 | 11 |
|
| 12 | + "github.com/cockroachdb/cockroach/pkg/kv/bulk" |
12 | 13 | "github.com/cockroachdb/cockroach/pkg/kv/kvpb"
|
13 | 14 | "github.com/cockroachdb/cockroach/pkg/kv/kvserver/kvserverbase"
|
14 | 15 | "github.com/cockroachdb/cockroach/pkg/roachpb"
|
@@ -78,6 +79,13 @@ var indexBackfillIngestConcurrency = settings.RegisterIntSetting(
|
78 | 79 | settings.PositiveInt, /* validateFn */
|
79 | 80 | )
|
80 | 81 |
|
| 82 | +var indexBackfillElasticCPUControlEnabled = settings.RegisterBoolSetting( |
| 83 | + settings.ApplicationLevel, |
| 84 | + "bulkio.index_backfill.elastic_control.enabled", |
| 85 | + "determines whether index backfill operations integrate with elastic CPU control", |
| 86 | + false, // TODO(dt): enable this by default after more benchmarking. |
| 87 | +) |
| 88 | + |
81 | 89 | func newIndexBackfiller(
|
82 | 90 | ctx context.Context,
|
83 | 91 | flowCtx *execinfra.FlowCtx,
|
@@ -329,9 +337,16 @@ func (ib *indexBackfiller) ingestIndexEntries(
|
329 | 337 | g.GoCtx(func(ctx context.Context) error {
|
330 | 338 | defer close(stopProgress)
|
331 | 339 |
|
| 340 | + // Create a pacer for admission control for index entry processing. |
| 341 | + pacer := bulk.NewCPUPacer(ctx, ib.flowCtx.Cfg.DB.KV(), indexBackfillElasticCPUControlEnabled) |
| 342 | + defer pacer.Close() |
| 343 | + |
332 | 344 | var vectorInputEntry rowenc.IndexEntry
|
333 | 345 | for indexBatch := range indexEntryCh {
|
334 | 346 | for _, indexEntry := range indexBatch.indexEntries {
|
| 347 | + // Pace the admission control before processing each index entry. |
| 348 | + pacer.Pace(ctx) |
| 349 | + |
335 | 350 | // If there is at least one vector index being written, we need to check to see
|
336 | 351 | // if this IndexEntry is going to a vector index and then re-encode it for that
|
337 | 352 | // index if so.
|
|
0 commit comments