Skip to content
Merged
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
3 changes: 2 additions & 1 deletion benchmark_runner/benchmark_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ func GetBenchmarkRunnerWithBatchSize(batchSize uint) *BenchmarkRunner {
flag.StringVar(&loader.JsonOutFile, "json-out-file", "", "Name of json output file to output benchmark results. If not set, will not print to json.")
flag.StringVar(&loader.Metadata, "metadata-string", "", "Metadata string to add to json-out-file. If -json-out-file is not set, will not use this option.")
flag.UintVar(&loader.maxTokenSizeMB, "max-token-size-mb", 1, "Maximum size of token to read from input file in MB. Minimum is 1MB.")
flag.UintVar(&loader.batchSize, "batch-size", batchSize, "Number of items to batch together per worker channel before dispatch.")
return loader
}

Expand Down Expand Up @@ -453,7 +454,7 @@ func (l *BenchmarkRunner) scan(b Benchmark, channels []*duplexChannel, start tim
}

resetFn := l.GetResetReaderFunc(b)
return scanWithTimeout(ctx, channels, 100, l.limit, l.Duration, l.br, b.GetCmdDecoder(l.br, l.maxTokenSizeMB), b.GetBatchFactory(), b.GetCommandIndexer(uint(len(channels))), resetFn)
return scanWithTimeout(ctx, channels, l.batchSize, l.limit, l.Duration, l.br, b.GetCmdDecoder(l.br, l.maxTokenSizeMB), b.GetBatchFactory(), b.GetCommandIndexer(uint(len(channels))), resetFn)
}

// work is the processing function for each worker in the loader
Expand Down
44 changes: 44 additions & 0 deletions benchmark_runner/redisearch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -555,3 +555,47 @@ func TestFTSBWithLogFileAndTimeout(t *testing.T) {

t.Log("Test passed: Log file captures timeout and error information correctly")
}

func TestFTSBWithBatchSize(t *testing.T) {
t.Log("Starting Redis container...")
dockerRun := exec.Command("docker", "run", "--rm", "-d", "-p", "6379:6379", "redis:8.4")
containerIDRaw, err := dockerRun.Output()
if err != nil {
t.Fatalf("Failed to start Redis container: %v", err)
}
containerID := strings.TrimSpace(string(containerIDRaw))

t.Cleanup(func() {
t.Log("Stopping Redis container...")
exec.Command("docker", "stop", containerID).Run()
})

t.Log("Waiting for Redis to be ready...")
time.Sleep(2 * time.Second)

t.Log("Running ftsb_redisearch with --batch-size=50 --duration=3s")
cmd := exec.Command("../bin/ftsb_redisearch",
"--input", "../testdata/minimal.csv",
"--batch-size=50",
"--duration=3s",
)
cmd.Env = append(os.Environ(), "REDIS_URL=redis://localhost:6379")
output, err := cmd.CombinedOutput()

if err != nil {
t.Fatalf("Benchmark failed: %v\nOutput: %s", err, string(output))
}

outputStr := string(output)
// Guards against the "flag provided but not defined: -batch-size" regression
// and against a reintroduction of the zero-batchSize panic.
if strings.Contains(outputStr, "flag provided but not defined") {
t.Errorf("--batch-size flag not registered; got: %s", outputStr)
}
if strings.Contains(outputStr, "panic:") {
t.Errorf("Benchmark panicked with --batch-size=50; got: %s", outputStr)
}
if !strings.Contains(outputStr, "Issued") {
t.Errorf("Expected benchmark output to contain 'Issued', got: %s", outputStr)
}
}
2 changes: 1 addition & 1 deletion cmd/ftsb_redisearch/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var (

// Parse args:
func init() {
loader = benchmark_runner.GetBenchmarkRunnerWithBatchSize(10)
loader = benchmark_runner.GetBenchmarkRunnerWithBatchSize(100)
flag.StringVar(&host, "host", "localhost:6379", "The host:port for Redis connection")
flag.StringVar(&password, "a", "", "Password for Redis Auth.")
flag.IntVar(&debug, "debug", 0, "Debug printing (choices: 0, 1, 2). (default 0)")
Expand Down
Loading