ycsb

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: Apache-2.0 Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const StreamingThreshold = 4 * 1024 * 1024 // 4MB

StreamingThreshold defines the size threshold (4MB) above which YCSB writes automatically use streaming.

Variables

View Source
var WorkloadPresets = map[string]WorkloadSpec{
	"A": {Weights: [OpNum]float64{0.5, 0.5}},
	"B": {Weights: [OpNum]float64{0.95, 0.05}},
	"C": {Weights: [OpNum]float64{1.0, 0}},
}

Functions

func DisplayFinalResults

func DisplayFinalResults(cfg YCSBConfig, result Result, totalOps []int)

DisplayFinalResults displays the final benchmark results using pterm tables

func DisplayFinalResultsWithMetrics

func DisplayFinalResultsWithMetrics(cfg YCSBConfig, result Result, totalOps []int, metrics *MetricsCollector)

DisplayFinalResultsWithMetrics displays the final benchmark results with enhanced metrics

func RenderHistogram

func RenderHistogram(buckets []HistogramBucket) string

RenderHistogram creates an ASCII histogram visualization

Types

type CASOutcome added in v1.12.0

type CASOutcome int

CASOutcome classifies the result of one guarded read-modify-write (OpCAS).

const (
	CASWin      CASOutcome = iota // the conditional write applied
	CASMismatch                   // lost the race: the expected outcome under contention, not an error
	CASError                      // a real failure
)

func ClassifyCASResult added in v1.12.0

func ClassifyCASResult(err error) (CASOutcome, error)

ClassifyCASResult maps a conditional-write result to its CAS outcome and the error to record. A lost race (VersionMismatchError) is a CASMismatch with a nil error — it is a benchmark outcome, never an error — so the classification lives here in the metrics layer and callers only count what it returns.

type HistogramBucket

type HistogramBucket struct {
	Min   time.Duration
	Max   time.Duration
	Count int
}

HistogramBucket represents a latency histogram bucket

type LatencySnapshot

type LatencySnapshot struct {
	P50  float64
	P95  float64
	P99  float64
	P999 float64
}

type MetricsCollector

type MetricsCollector struct {
	// contains filtered or unexported fields
}

MetricsCollector collects detailed metrics during benchmark execution

func NewMetricsCollector

func NewMetricsCollector() *MetricsCollector

NewMetricsCollector creates a new metrics collector

func (*MetricsCollector) GetErrorBreakdown

func (mc *MetricsCollector) GetErrorBreakdown() (byType map[string]int, byOp map[OpType]int)

GetErrorBreakdown returns detailed error categorization

func (*MetricsCollector) GetHistogram

func (mc *MetricsCollector) GetHistogram() []HistogramBucket

GetHistogram returns the latency histogram

func (*MetricsCollector) GetPerOperationStats

func (mc *MetricsCollector) GetPerOperationStats() map[OpType]OperationStats

GetPerOperationStats returns statistics for each operation type

func (*MetricsCollector) GetThroughputSeries

func (mc *MetricsCollector) GetThroughputSeries() []ThroughputPoint

GetThroughputSeries returns the throughput time series

func (*MetricsCollector) RecordOperation

func (mc *MetricsCollector) RecordOperation(opType OpType, latency time.Duration, err error)

RecordOperation records a single operation's metrics

func (*MetricsCollector) RecordThroughput

func (mc *MetricsCollector) RecordThroughput(opsPerSec float64, opType OpType)

RecordThroughput records throughput at current time

type OpType

type OpType int
const (
	OpRead OpType = iota
	OpUpdate
	// OpCAS is one guarded read-modify-write: GetWithVersion, then PutIfVersion
	// against the version just read. This is the write-coordination pattern CAS
	// exists for (issue #254). Losing the race (a VersionMismatchError) is the
	// expected outcome under contention and is counted as a mismatch, not an
	// error; the mismatch rate is the contention signal the benchmark reports.
	OpCAS
	OpNum
)

type OperationStats

type OperationStats struct {
	Count       int
	ErrorCount  int
	MinLatency  time.Duration
	MaxLatency  time.Duration
	AvgLatency  time.Duration
	P50Latency  time.Duration
	P95Latency  time.Duration
	P99Latency  time.Duration
	P999Latency time.Duration
}

OperationStats holds statistics for a single operation type

type PtermProgressReporter

type PtermProgressReporter struct {
	// contains filtered or unexported fields
}

PtermProgressReporter handles real-time progress reporting using pterm

func NewPtermProgressReporter

func NewPtermProgressReporter(totalOps int) *PtermProgressReporter

NewPtermProgressReporter creates a new pterm-based progress reporter

func (*PtermProgressReporter) GetStats

func (pr *PtermProgressReporter) GetStats() (completed int64, errors int64, opCounts []int64)

GetStats returns final statistics

func (*PtermProgressReporter) RecordOp

func (pr *PtermProgressReporter) RecordOp(opType OpType, latency time.Duration, err error)

RecordOp records a completed operation

func (*PtermProgressReporter) Start

func (pr *PtermProgressReporter) Start() error

Start begins the progress reporting

func (*PtermProgressReporter) Stop

func (pr *PtermProgressReporter) Stop()

Stop stops the progress reporting

func (*PtermProgressReporter) UpdateLatencies

func (pr *PtermProgressReporter) UpdateLatencies(p50, p95, p99, p999 float64)

UpdateLatencies updates the latency snapshot

type Result

type Result struct {
	Ops       int
	Duration  time.Duration
	Errors    int
	Latencies []time.Duration // All operation latencies

	// Guarded read-modify-write (OpCAS) outcomes. A mismatch is a lost race —
	// the expected outcome under contention — and is never counted in Errors.
	CASAttempts   int
	CASWins       int
	CASMismatches int
}

func RunYCSB

func RunYCSB(cfg YCSBConfig) (Result, error)

func RunYCSBWithContext

func RunYCSBWithContext(ctx context.Context, cfg YCSBConfig) (Result, error)

type ThroughputPoint

type ThroughputPoint struct {
	Time      time.Duration // Time since start
	OpsPerSec float64
	OpType    OpType
}

ThroughputPoint represents throughput at a point in time

type ThroughputSummary

type ThroughputSummary struct {
	MinThroughput    float64
	MaxThroughput    float64
	AvgThroughput    float64
	StdDevThroughput float64
	ThroughputTrend  string // "increasing", "decreasing", "stable"
}

ThroughputSummary provides summary of throughput over time

func AnalyzeThroughput

func AnalyzeThroughput(series []ThroughputPoint) ThroughputSummary

AnalyzeThroughput analyzes throughput time series

type WorkloadSpec

type WorkloadSpec struct {
	Weights [OpNum]float64 // Fraction for each op type
}

WorkloadSpec defines the operation mix for a workload.

func ParseWorkload

func ParseWorkload(s string) (WorkloadSpec, error)

type YCSBConfig

type YCSBConfig struct {
	Addr               string        // Address of the cache service (host:port or comma-separated)
	ConnMode           string        // Connection mode: auto, simple, or cluster
	TopologyRefresh    time.Duration // Topology refresh interval (cluster mode only)
	ConnectionPoolSize int           // Number of connections per address (default: 4)
	NumKeys            int           // Number of unique keys to use in the benchmark
	ValueSize          int           // Size of each value in bytes
	NumOps             int           // Total number of operations to perform
	Concurrency        int           // Number of concurrent workers
	Workload           string        // Workload type or custom mix (e.g. "A", "B", "read=70,update=30")
	Seed               int64         // Seed for random number generation (for reproducibility)
	NoProgress         bool          // Disable progress output during benchmark
	ForceStreaming     bool          // Force streaming for writes regardless of size; reads always stream
}

Jump to

Keyboard shortcuts

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