Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/round/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func processRoundDecimalFile(inputPath string) (err error) {
if err != nil {
return err
}
bufWriter = bufio.NewWriter(outputFile)
bufWriter = bufio.NewWriterSize(outputFile, 8192)
colCount = len(cols)
} else {
// no decimal column, quick exit
Expand Down
7 changes: 7 additions & 0 deletions stage/map.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ func ParseStage(stage *Stage, stages Map) (*Stage, error) {
}
}
stages[stage.Id] = stage

// Set the seed for this stage (only relevant for non-stream stages)
// Stream stages will have their seeds set during runAsMultipleStreams
if stage.StreamCount == nil || *stage.StreamCount <= 1 {
stage.seed = stage.States.RandSeed
}

for _, nextStagePath := range stage.NextStagePaths {
if nextStage, err := ParseStageFromFile(nextStagePath, stages); err != nil {
return nil, err
Expand Down
11 changes: 7 additions & 4 deletions stage/mysql_run_recorder.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import (
"context"
"database/sql"
_ "embed"
_ "github.com/go-sql-driver/mysql"
"pbench/log"
"pbench/utils"

_ "github.com/go-sql-driver/mysql"
)

var (
Expand Down Expand Up @@ -65,7 +66,7 @@ VALUES (?, ?, ?, 0, 0, 0, ?)`

func (m *MySQLRunRecorder) RecordQuery(_ context.Context, s *Stage, result *QueryResult) {
recordNewQuery := `INSERT INTO pbench_queries (run_id, stage_id, query_file, query_index, query_id, sequence_no,
cold_run, succeeded, start_time, end_time, row_count, expected_row_count, duration_ms, info_url) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
cold_run, succeeded, start_time, end_time, row_count, expected_row_count, duration_ms, info_url, seed) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update pbench_queries_ddl.sql with the new column

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And why do we need a seed in this table?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are two tables, pbench_runs and pbench_queries. Currently pbench_runs has a seed column, but with this additional functionality to be able to seed each stream, there had to be some way to add reporting for multiple seeds in a run. The simplest way I found to do it was to add 'seed' as a column to pbench_queries and group by stage_id to be able to present it in Grafana.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was looking for other ways to report seed per stream, please let me know if you have any suggestions.

var queryFile string
if result.Query.File != nil {
queryFile = *result.Query.File
Expand All @@ -83,11 +84,13 @@ cold_run, succeeded, start_time, end_time, row_count, expected_row_count, durati
result.RowCount, sql.NullInt32{
Int32: int32(result.Query.ExpectedRowCount),
Valid: result.Query.ExpectedRowCount >= 0,
}, result.Duration.Milliseconds(), result.InfoUrl)
}, result.Duration.Milliseconds(), result.InfoUrl, result.Seed)
log.Info().Str("stage_id", result.StageId).Stringer("start_time", result.StartTime).Stringer("end_time", result.EndTime).
Str("info_url", result.InfoUrl).Int64("seed", result.Seed).Msg("recorded query result to MySQL")
if err != nil {
log.Error().EmbedObject(result).Err(err).Msg("failed to send query summary to MySQL")
}
updateRunInfo := `UPDATE pbench_runs SET start_time = ?, queries_ran = queries_ran + 1, failed = ?, mismatch = ? WHERE run_id = ?`
updateRunInfo := `UPDATE pbench_runs SET start_time = ?, queries_ran = queries_ran + 1, failed = ? , mismatch = ? WHERE run_id = ?`
res, err := m.db.Exec(updateRunInfo, s.States.RunStartTime, m.failed, m.mismatch, m.runId)
if err != nil {
log.Error().Err(err).Str("run_name", s.States.RunName).Int64("run_id", m.runId).
Expand Down
1 change: 1 addition & 0 deletions stage/pbench_queries_ddl.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ create table if not exists pbench_queries
expected_row_count int null,
duration_ms int not null,
info_url varchar(255) not null,
seed bigint not null,
primary key (run_id, stage_id, query_file, query_index, sequence_no)
)
partition by hash (`run_id`) partitions 16;
Expand Down
4 changes: 3 additions & 1 deletion stage/result.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package stage

import (
"github.com/rs/zerolog"
"pbench/log"
"time"

"github.com/rs/zerolog"
)

type QueryResult struct {
StageId string
Seed int64
Query *Query
QueryId string
InfoUrl string
Expand Down
Loading