Skip to content

Commit 3e8bb84

Browse files
roachtest: fix perf artifacts not processing
This commit fixes an issue in the test runner that prevented performance artifacts from being properly processed. When perf artifcats directory for the benchmark is not defined, we default to finding files in every node, however the current implementation returns when the files are not found in the first node rather than moving forward. Also, this change makes sure we write to only those directory from where the perf artifacts are fetched. Epic: none Release note: None
1 parent cd1e806 commit 3e8bb84

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

pkg/cmd/roachtest/test_runner.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,10 @@ type perfMetricsCollector struct {
181181
// elapsed is the avg elapsed time of the run
182182
elapsed int64
183183
// count is the count of perf files
184-
count int64
185-
t *testImpl
186-
ctx context.Context
184+
count int64
185+
t *testImpl
186+
ctx context.Context
187+
perfNodes []int
187188
}
188189

189190
// newTestRunner constructs a testRunner.
@@ -2024,26 +2025,27 @@ func (r *testRunner) postProcessPerfMetrics(
20242025
}
20252026

20262027
// Collect and aggregate metrics from all relevant nodes
2027-
if err := metrics.collectFromNodes(c, dstDirFn); err != nil {
2028+
if err := metrics.collectFromNodes(c, dstDirFn, t.L()); err != nil {
20282029
t.L().PrintfCtx(ctx, "failed to collect metrics: %v", err)
20292030
return
20302031
}
20312032

20322033
// Process and write aggregated metrics
2033-
if err := metrics.processAndWrite(c, dstDirFn); err != nil {
2034+
if err := metrics.processAndWrite(dstDirFn); err != nil {
20342035
t.L().PrintfCtx(ctx, "failed to process and write metrics: %v", err)
20352036
}
20362037
}
20372038

20382039
func (m *perfMetricsCollector) collectFromNodes(
2039-
c *clusterImpl, dstDirFn func(nodeIdx int) string,
2040+
c *clusterImpl, dstDirFn func(nodeIdx int) string, log *logger.Logger,
20402041
) error {
20412042
for _, node := range getPerfArtifactsNode(c) {
20422043
files, err := m.findMetricsFiles(dstDirFn(node))
20432044
if err != nil {
2044-
return errors.Wrapf(err, "finding metrics files")
2045+
log.Printf("failed to find metrics files for node %d will continue: %s", node, err)
2046+
continue
20452047
}
2046-
2048+
m.perfNodes = append(m.perfNodes, node)
20472049
if err := m.processFiles(files); err != nil {
20482050
return errors.Wrapf(err, "error while processing files")
20492051
}
@@ -2085,9 +2087,7 @@ func (m *perfMetricsCollector) processFiles(files []string) error {
20852087
return nil
20862088
}
20872089

2088-
func (m *perfMetricsCollector) processAndWrite(
2089-
c *clusterImpl, dstDirFn func(nodeIdx int) string,
2090-
) error {
2090+
func (m *perfMetricsCollector) processAndWrite(dstDirFn func(nodeIdx int) string) error {
20912091
if m.count == 0 {
20922092
return errors.New("no metrics files found")
20932093
}
@@ -2109,8 +2109,8 @@ func (m *perfMetricsCollector) processAndWrite(
21092109
return errors.Wrapf(err, "converting metrics to bytes")
21102110
}
21112111

2112-
// Write the file and take the first node of the cluster
2113-
outputPath := filepath.Join(dstDirFn(getPerfArtifactsNode(c)[0]), "aggregated_stats.om")
2112+
// Write the file to the first directory of any node where perf artifacts are present
2113+
outputPath := filepath.Join(dstDirFn(m.perfNodes[0]), "aggregated_stats.om")
21142114
return os.WriteFile(outputPath, finalMetricsBuffer.Bytes(), 0644)
21152115
}
21162116

0 commit comments

Comments
 (0)