metadata

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package metadata collects the reproducibility metadata every full benchmark run must capture (issue #141 "Reproducibility metadata"): enough about the host, toolchain, and run parameters that a published table can be reproduced. "Never publish a table without enough metadata to reproduce it."

Index

Constants

View Source
const SchemaVersion = 1

SchemaVersion is bumped when the Metadata shape changes incompatibly.

Variables

This section is empty.

Functions

func WriteJSON

func WriteJSON(w io.Writer, m Metadata) error

WriteJSON encodes the metadata as pretty-printed JSON (results/latest/ metadata.json).

Types

type Metadata

type Metadata struct {
	SchemaVersion int    `json:"schema_version"`
	Timestamp     string `json:"timestamp"`

	GitCommit string `json:"git_commit"`
	// GitDirty is a pointer, not a bool, so the metadata can honestly say "I
	// did not determine this" (null) when `git status` failed or git was
	// missing — a plain bool's zero value (false = clean) would claim a
	// clean tree on the exact runs where the check could not run.
	GitDirty *bool `json:"git_dirty"`

	OS          string `json:"os"`
	Kernel      string `json:"kernel"`
	Arch        string `json:"arch"`
	CPUModel    string `json:"cpu_model"`
	LogicalCPUs int    `json:"logical_cpus"`
	RAMBytes    int64  `json:"ram_bytes"`

	GoVersion            string `json:"go_version"`
	DockerVersion        string `json:"docker_version"`
	DockerComposeVersion string `json:"docker_compose_version"`
	PostgresVersion      string `json:"postgres_version"`

	FrameworkVersions map[string]string `json:"framework_versions"`
	RuntimeVersions   map[string]string `json:"runtime_versions"`
	BenchmarkTool     string            `json:"benchmark_tool"`

	// ResourceLimits is the single scalar the standalone/host-only path records
	// (an intended budget). For a multi-app run the authoritative field is
	// ResourceLimitsByFramework: the *applied* verdict verified per app (from
	// inspect-limits), preserved by merge so a partial/not-applied on one app is
	// never overwritten by an enforced on the next. PostgresResourceLimits is the
	// database container's verified verdict.
	ResourceLimits            string            `json:"resource_limits"`
	ResourceLimitsByFramework map[string]string `json:"resource_limits_by_framework"`
	PostgresResourceLimits    string            `json:"postgres_resource_limits"`
	DurationSeconds           float64           `json:"duration_seconds"`
	WarmupSeconds             float64           `json:"warmup_seconds"`
	Concurrency               []int             `json:"concurrency"`
	Trials                    int               `json:"trials"`
}

Metadata is the machine-readable run environment (written to results/latest/metadata.json). Discovered fields come from the host and toolchain; the rest are run parameters the orchestrator supplies via Options because they are choices, not facts about the machine.

func Collect

func Collect(ctx context.Context, opts Options) Metadata

Collect gathers the metadata. Discovery is best-effort: a missing tool (docker on a CI runner without it, git outside a checkout) leaves its field empty rather than failing the whole collection — a benchmark run should still record everything it *can*.

type Options

type Options struct {
	Now func() time.Time
	Run Runner

	PostgresVersion           string
	FrameworkVersions         map[string]string
	RuntimeVersions           map[string]string
	BenchmarkTool             string
	ResourceLimits            string
	ResourceLimitsByFramework map[string]string
	PostgresResourceLimits    string
	DurationSeconds           float64
	WarmupSeconds             float64
	Concurrency               []int
	Trials                    int
}

Options carries the injectable seams (Now, Run) and the run-parameter fields the orchestrator knows but the host does not.

type Runner

type Runner func(ctx context.Context, name string, args ...string) (string, error)

Runner runs a command and returns its trimmed stdout. It exists so tests can stub git/uname/docker without those tools being installed; production uses execRunner.

Jump to

Keyboard shortcuts

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