Skip to content

nats bench should publish random data, not zeroes? #1559

@alexbozhenko

Description

@alexbozhenko

Proposed change

We publish zeroes here:

buffer := make([]byte, msgSize)

This may skew the results because of compression usage, etc.
Should probably use https://pkg.go.dev/crypto/rand#Read

Also related, when --payload is used:

natscli/cli/bench_command.go

Lines 1749 to 1752 in f479ef0

buffer, err := os.ReadFile(c.payloadFilename)
if err != nil {
return nil, fmt.Errorf("reading the payload file: %w", err)
}

It problably makes sense to read the file only once, not once per client, to make this work:

nats bench pub hello --clients=30 --msgs=30 --payload <(head --bytes=1M /dev/urandom)

Otherwise, the named pipe that bash creates is "split" across N goroutines reading it concurrently. So total published size will be 1M, not 30M in this case.

Use case

Benchmarks that are closer resemble real workloads.

Contribution

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    proposalEnhancement idea or proposal

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions