@@ -14,6 +14,7 @@ import (
14
14
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/cluster"
15
15
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/option"
16
16
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/registry"
17
+ "github.com/cockroachdb/cockroach/pkg/cmd/roachtest/roachtestutil"
17
18
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/roachtestutil/task"
18
19
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/spec"
19
20
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/test"
@@ -339,11 +340,40 @@ func makeSchemaChangeBulkIngestTest(
339
340
return registry.TestSpec {
340
341
Name : "schemachange/bulkingest" ,
341
342
Owner : registry .OwnerSQLFoundations ,
343
+ Benchmark : true ,
342
344
Cluster : r .MakeClusterSpec (numNodes , spec .WorkloadNode (), spec .SSD (4 )),
343
345
CompatibleClouds : registry .AllExceptAWS ,
344
346
Suites : registry .Suites (registry .Nightly ),
345
347
Leases : registry .MetamorphicLeases ,
346
348
Timeout : length * 2 ,
349
+ PostProcessPerfMetrics : func (test string , histogram * roachtestutil.HistogramMetric ) (roachtestutil.AggregatedPerfMetrics , error ) {
350
+ // The histogram tracks the total elapsed time for the CREATE INDEX operation.
351
+ totalElapsed := histogram .Elapsed
352
+
353
+ // Calculate the approximate data size for the index.
354
+ // The index is on (payload, a) where payload is 40 bytes.
355
+ // Approximate size per row for index: 40 bytes (payload) + 8 bytes (a) = 48 bytes
356
+ rowsIndexed := int64 (numRows )
357
+ bytesPerRow := int64 (48 )
358
+ mb := int64 (1 << 20 )
359
+ dataSizeInMB := (rowsIndexed * bytesPerRow ) / mb
360
+
361
+ // Calculate throughput in MB/s per node.
362
+ indexDuration := int64 (totalElapsed / 1000 ) // Convert to seconds.
363
+ if indexDuration == 0 {
364
+ indexDuration = 1 // Avoid division by zero.
365
+ }
366
+ avgRatePerNode := roachtestutil .MetricPoint (float64 (dataSizeInMB ) / float64 (int64 (numNodes )* indexDuration ))
367
+
368
+ return roachtestutil.AggregatedPerfMetrics {
369
+ {
370
+ Name : fmt .Sprintf ("%s_throughput" , test ),
371
+ Value : avgRatePerNode ,
372
+ Unit : "MB/s/node" ,
373
+ IsHigherBetter : true ,
374
+ },
375
+ }, nil
376
+ },
347
377
// `fixtures import` (with the workload paths) is not supported in 2.1
348
378
Run : func (ctx context.Context , t test.Test , c cluster.Cluster ) {
349
379
// Configure column a to have sequential ascending values. The payload
@@ -372,6 +402,11 @@ func makeSchemaChangeBulkIngestTest(
372
402
373
403
c .Run (ctx , option .WithNodes (c .WorkloadNode ()), cmdWrite )
374
404
405
+ // Set up histogram exporter for performance metrics.
406
+ exporter := roachtestutil .CreateWorkloadHistogramExporter (t , c )
407
+ tickHistogram , perfBuf := initBulkJobPerfArtifacts (length * 2 , t , exporter )
408
+ defer roachtestutil .CloseExporter (ctx , exporter , t , c , perfBuf , c .Node (1 ), "" )
409
+
375
410
m := c .NewDeprecatedMonitor (ctx , c .CRDBNodes ())
376
411
377
412
indexDuration := length
@@ -402,10 +437,14 @@ func makeSchemaChangeBulkIngestTest(
402
437
}
403
438
404
439
t .L ().Printf ("Creating index" )
440
+ // Tick once before starting the index creation.
441
+ tickHistogram ()
405
442
before := timeutil .Now ()
406
443
if _ , err := db .Exec (`CREATE INDEX payload_a ON bulkingest.bulkingest (payload, a)` ); err != nil {
407
444
t .Fatal (err )
408
445
}
446
+ // Tick once after the index creation to capture the total elapsed time.
447
+ tickHistogram ()
409
448
t .L ().Printf ("CREATE INDEX took %v\n " , timeutil .Since (before ))
410
449
return nil
411
450
})
0 commit comments