bench

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckRange

func CheckRange(rows, expected []KV) error

func CheckValue

func CheckValue(actual, expected []byte) error

func Payload

func Payload(size, worker, index int, phase byte) []byte

func PoissonSchedule

func PoissonSchedule(n int, rate float64, seed, stream uint64) ([]int64, error)

PoissonSchedule returns n start offsets in nanoseconds with exponential gaps averaging 1/rate seconds, from seed and stream: evenly spread on average, pseudo-random in detail. Streams give one seed independent schedules.

func Run

func Run(cfg Config, db LifecycleDatabase, metadata map[string]any, afterIdentity Stats) error

func StartProfile

func StartProfile(mode, dir string) (func() error, error)

func ValidateGRVWorkload

func ValidateGRVWorkload(delta ClientCounters, workload string, completed int) error

func WriteJSON

func WriteJSON(path string, value any) error

func WriteSamples

func WriteSamples(path, phase string, samples []Sample) error

Types

type CleanupCounters

type CleanupCounters struct {
	FinalizersQueued   uint64 `json:"finalizers_queued"`
	FinalizersExecuted uint64 `json:"finalizers_executed"`
	CleanupsQueued     uint64 `json:"cleanups_queued_estimate"`
	CleanupsExecuted   uint64 `json:"cleanups_executed_estimate"`
	GCCycles           uint64 `json:"gc_cycles"`
}

type ClientCounters

type ClientCounters struct {
	Observation string           `json:"observation"`
	Values      map[string]int64 `json:"values,omitempty"`
}

Native libfdb_c does not expose these counters through its public C API. Unobserved is distinct from an observed zero.

func CounterDelta

func CounterDelta(before, after ClientCounters) (ClientCounters, error)

type Config

type Config struct {
	ClusterFile    string `json:"cluster_file"`
	Workload       string `json:"workload"`
	Iterations     int    `json:"iterations"`
	Warmup         int    `json:"warmup"`
	Workers        int    `json:"workers"`
	Output         string `json:"output"`
	RunID          string `json:"run_id"`
	Block          int    `json:"block"`
	SourceRevision string `json:"source_revision"`
	HarnessID      string `json:"harness_id"`
	AllowWrites    bool   `json:"allow_writes"`
	Prefix         string `json:"prefix"`
	TimeoutMS      int64  `json:"transaction_timeout_ms"`
	RetryLimit     int64  `json:"retry_limit"`
	Profile        string `json:"profile"`
	// CoalesceDelay is the Go client's connection write delay, "min,max" as Go
	// durations; empty keeps the client default.
	CoalesceDelay string `json:"coalesce_delay,omitempty"`
	// AdaptiveLinger is the Go client's Nagle-style adaptive linger window; 0 keeps the default.
	AdaptiveLinger time.Duration `json:"adaptive_linger_ns,omitempty"`
	// Rate > 0 paces the run: operations start at Poisson arrival times averaging
	// Rate per second, drawn from Seed, so every run with the same seed starts the
	// same operations at the same offsets. Rate 0 is a closed loop.
	Rate float64 `json:"rate,omitempty"`
	Seed uint64  `json:"seed"`
	// Duration selects fixed-time closed-loop mode; zero preserves count mode.
	Duration       time.Duration `json:"duration_ns,omitempty"`
	WarmupDuration time.Duration `json:"warmup_duration_ns,omitempty"`
}

func (Config) Validate

func (c Config) Validate() error

type Database

type Database interface {
	Transact(readOnly bool, fn func(Transaction) error) error
	Local(fn func(Transaction) error) error
	Counters() ClientCounters
	Close()
}

type Dataset

type Dataset struct {
	Points          map[int]KV
	Range           []KV
	RangeEnd        []byte
	Writes          [][]byte
	Initial         []byte
	Warmup, Measure [][]byte
	BatchWrites     [][][]byte
	BatchInitial    [][]byte
	BatchValueBytes int
}

func Prepare

func Prepare(prefix string, workers, warmup, iterations int) Dataset

func (Dataset) Operation

func (d Dataset) Operation(db Database, workload string, worker int, payload []byte) (attempts int, err error)

func (*Dataset) PrepareBatchSet50

func (d *Dataset) PrepareBatchSet50(prefix string)

PrepareBatchSet50 pregenerates worker-local keys and operands so none of their allocation or formatting enters the measured phase.

func (Dataset) Seed

func (d Dataset) Seed(db Database) error

func (Dataset) ValidateSeed

func (d Dataset) ValidateSeed(db Database) error

func (Dataset) ValidateWrites

func (d Dataset) ValidateWrites(db Database, workload string, warmup, measured int) error

type FinalizerDrain

type FinalizerDrain struct {
	Before   CleanupCounters `json:"before"`
	After    CleanupCounters `json:"after"`
	Rounds   int             `json:"rounds"`
	WallNS   int64           `json:"wall_ns"`
	Complete bool            `json:"complete"`
}

func DrainFinalizers

func DrainFinalizers() (FinalizerDrain, error)

type KV

type KV struct{ Key, Value []byte }

type Lifecycle

type Lifecycle struct {
	MeasurementDrain   FinalizerDrain `json:"measurement_drain"`
	MeasurementBarrier bool           `json:"measurement_barrier_complete"`
	AfterDrain         Stats          `json:"stats_after_measurement_drain"`
	ShutdownDrain      FinalizerDrain `json:"shutdown_drain"`
	DatabaseClosed     bool           `json:"database_closed"`
	NetworkStopped     bool           `json:"network_stopped"`
	AfterShutdown      Stats          `json:"stats_after_shutdown"`
	Complete           bool           `json:"complete"`
}

type LifecycleDatabase

type LifecycleDatabase interface {
	Database
	Barrier() error
	Shutdown() (networkStopped bool, err error)
}

LifecycleDatabase is owned by one benchmark process; Shutdown is terminal.

type Pacing

type Pacing struct {
	LagP50NS, LagP99NS, LagMaxNS int64
	LateOver100us, LateOver1ms   float64
	GapCVActual, GapCVScheduled  float64
	Samples                      int
}

Pacing reports how closely a paced phase's actual starts followed its schedule: start lag (actual - scheduled start) and the coefficient of variation of the gaps between consecutive starts, actual and scheduled (about 1 for Poisson arrivals; bunched starts raise it, regularized starts lower it).

type Phase

type Phase struct {
	Samples                    []Sample
	WallNS                     int64
	Completed, Errors, Retries int
	Before, After              Stats
	StatsError                 error
}

func RunPhase

func RunPhase(count, workers int, operation func(index, worker int) (int, error)) Phase

RunPhase excludes generation, goroutine creation, CSV formatting and stats collection. Latencies include retries, full materialization and exact checks.

type Sample

type Sample struct {
	Index, Worker            int
	StartOffsetNS, LatencyNS int64
	// ScheduledOffsetNS is the paced start time; -1 in a closed loop.
	ScheduledOffsetNS int64
	Attempts          int
	Err               error
	Attempted         bool
}

type Stats

type Stats struct {
	TotalAlloc uint64 `json:"go_total_alloc_bytes"`
	Mallocs    uint64 `json:"go_mallocs"`
	GC         uint32 `json:"go_gc_cycles"`
	GCPause    uint64 `json:"go_gc_pause_ns"`
	UserUS     int64  `json:"process_user_cpu_us"`
	SystemUS   int64  `json:"process_system_cpu_us"`
	MaxRSSKB   int64  `json:"process_high_water_rss_kb"`
}

func ReadStats

func ReadStats(after bool) (Stats, error)

type Transaction

type Transaction interface {
	Get([]byte) ([]byte, error)
	Set([]byte, []byte)
	Range([]byte, []byte, int) ([]KV, error)
	ReadVersion() (int64, error)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL