Help us shape the future of Go! Take the 2026 Go Developer Survey

bench

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package bench is a POSIX filesystem benchmark for an mlfs mount. It runs only standard file operations against a target directory, so it measures the mount exactly as a workload sees it — no metadata-DB or chunk-store coupling — which lets it ship in a small standalone binary deployable onto any pod that mounts mlfs storage. It exercises the two profiles that dominate real use: one large sequential file (write-back + read-back throughput) and many small files (create/stat/read latency, i.e. the metadata path).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Dir        string        // parent directory (under the mount); a temp work dir is created here
	BigSize    int64         // total bytes for the large-file phase
	BlockSize  int           // I/O block size for the large-file phase
	SmallFiles int           // number of small files for the metadata phase
	SmallSize  int           // bytes per small file
	Fsync      bool          // fsync after each write (measure the durable path)
	DropCache  bool          // fadvise DONTNEED before the read phase (force a cold read)
	Keep       bool          // keep the work dir instead of removing it
	Timeout    time.Duration // overall deadline (0 = none)
}

Config controls a benchmark run. Bind it to a flag set with Flags.

func Flags

func Flags(fs *flag.FlagSet) *Config

Flags registers the benchmark flags on fs and returns a Config populated after fs.Parse runs. Shared so every binary exposes an identical surface.

type Result

type Result struct {
	WorkDir string `json:"work_dir"`

	BigBytes     int64   `json:"big_bytes"`
	WriteSeconds float64 `json:"write_seconds"`
	ReadSeconds  float64 `json:"read_seconds"`
	WriteMiBps   float64 `json:"write_mibps"`
	ReadMiBps    float64 `json:"read_mibps"`

	SmallFiles    int     `json:"small_files"`
	SmallSize     int     `json:"small_size"`
	CreateSeconds float64 `json:"create_seconds"`
	StatSeconds   float64 `json:"stat_seconds"`
	ReadSeconds2  float64 `json:"small_read_seconds"`
	CreateIOPS    float64 `json:"create_iops"`
	StatIOPS      float64 `json:"stat_iops"`
	ReadIOPS      float64 `json:"small_read_iops"`

	Fsync bool `json:"fsync"`
}

Result holds the measured throughput and rates of one run.

func Run

func Run(ctx context.Context, cfg Config) (Result, error)

Run executes the benchmark and returns its measurements. It creates (and, unless Keep, removes) a temp work directory under cfg.Dir.

func (Result) Print

func (r Result) Print(w io.Writer)

Print renders the result as an aligned, human-readable report to w.

Jump to

Keyboard shortcuts

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