selfbench

package
v0.102.1 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 25 Imported by: 1 module, 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

Overview

Package selfbench measures file-discovered Flow workloads in process.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RenderActionTree added in v0.100.1

func RenderActionTree(w io.Writer, actions []ActionProfile) error

RenderActionTree writes action spans in parent-child order. Inclusive wall time includes descendants; self wall time subtracts the union of direct child intervals and is not CPU time.

func RenderCPUProfileSummary added in v0.100.1

func RenderCPUProfileSummary(w io.Writer, summary CPUProfileSummary) error

RenderCPUProfileSummary writes the saved pprof path and readable top functions. It is suitable for stderr so command output and JSON remain clean.

func Run

func Run(ctx context.Context, cfg runner.Config, scenarios []Scenario, opts Options) int

Run returns 0 on success, 1 on compilation/execution/output failure, and 2 on invalid options. Config must belong to the caller's live runner Host.

Types

type ActionProfile added in v0.99.0

type ActionProfile struct {
	Action     string  `json:"action"`
	Path       string  `json:"path"`
	Parent     string  `json:"parent,omitempty"`
	Depth      int     `json:"depth"`
	Calls      int     `json:"calls"`
	Errors     int     `json:"errors,omitempty"`
	Retries    int     `json:"retries,omitempty"`
	TotalMs    float64 `json:"total_ms"`
	SelfMs     float64 `json:"self_ms"`
	MeanMs     float64 `json:"mean_ms"`
	MeanSelfMs float64 `json:"mean_self_ms"`
	MaxMs      float64 `json:"max_ms"`
	MaxSelfMs  float64 `json:"max_self_ms"`
}

ActionProfile aggregates one node in an action call tree across measured runs. TotalMs is inclusive wall time; SelfMs subtracts the union of direct child spans and is therefore exclusive wall time, not CPU time.

type ActionProfiler added in v0.100.1

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

ActionProfiler records action invocations while enabled. Hooks are attached to resolved actions and streams by runner.Config.Hooks, so nested executions inherit parent spans through their context.

func NewActionProfiler added in v0.100.1

func NewActionProfiler() *ActionProfiler

NewActionProfiler constructs a profiler ready to be attached to a runner.

func (*ActionProfiler) Hook added in v0.100.1

func (p *ActionProfiler) Hook() action.AnyHook

Hook returns the Kernel hook that records action start, completion, errors, and retries. Install it in runner.Config.Hooks before compiling the workflow.

func (*ActionProfiler) Snapshot added in v0.100.1

func (p *ActionProfiler) Snapshot() []ActionProfile

Snapshot returns action call-tree aggregates sorted by path. Child intervals are merged before subtraction, so concurrent overlapping siblings are never subtracted twice from their parent's exclusive wall time.

func (*ActionProfiler) Start added in v0.100.1

func (p *ActionProfiler) Start()

Start clears prior measurements and begins recording. It is safe to reuse a profiler for separate measured windows after the previous window has stopped.

func (*ActionProfiler) Stop added in v0.100.1

func (p *ActionProfiler) Stop()

Stop ends the current measurement window. Already-started spans still finish normally and remain in the snapshot.

type AllocationPerRun added in v0.99.0

type AllocationPerRun struct {
	Runs              int     `json:"runs"`
	AllocationsPerRun float64 `json:"allocations_per_run"`
	BytesPerRun       float64 `json:"bytes_per_run"`
}

AllocationPerRun summarizes allocations over repeated runs.

type AllocationStats added in v0.99.0

type AllocationStats struct {
	Allocations uint64 `json:"allocations"`
	Bytes       uint64 `json:"bytes"`
}

AllocationStats counts Go heap allocations made during a phase. Bytes are cumulative allocated bytes, not live heap size or resident memory.

type CPUProfile added in v0.100.1

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

CPUProfile controls one process-wide CPU profile. Go permits only one active CPU profile per process; call Stop before starting another profile.

func StartCPUProfile added in v0.100.1

func StartCPUProfile(path string) (*CPUProfile, error)

StartCPUProfile starts recording CPU samples from the current process to path. The resulting file is a standard Go pprof profile.

func (*CPUProfile) Stop added in v0.100.1

func (p *CPUProfile) Stop() (CPUProfileSummary, error)

Stop flushes and closes the profile, then attempts to render its top functions. It is idempotent and safe to call from cleanup paths.

type CPUProfileSummary added in v0.100.1

type CPUProfileSummary struct {
	Path          string `json:"path"`
	TopFunctions  string `json:"top_functions,omitempty"`
	AnalysisError string `json:"analysis_error,omitempty"`
}

CPUProfileSummary identifies the saved profile and includes the readable output of `go tool pprof -top`. AnalysisError is non-fatal: the pprof file is still useful even when the Go tool or symbols are unavailable on this host.

type Options

type Options struct {
	Out            io.Writer
	Iterations     int
	Warmup         int
	JSON           bool
	List           bool
	Profile        bool
	CPUProfilePath string
}

Options controls measurement; zero warmup is meaningful.

type Report

type Report struct {
	Version    int      `json:"version"`
	GoVersion  string   `json:"go_version"`
	OS         string   `json:"os"`
	Arch       string   `json:"arch"`
	CPUs       int      `json:"cpus"`
	GOMAXPROCS int      `json:"gomaxprocs"`
	Profiled   bool     `json:"profiled"`
	Results    []Result `json:"results"`
}

type Result

type Result struct {
	Name               string                  `json:"name"`
	CompileMs          float64                 `json:"compile_ms"`
	CompileAllocation  AllocationStats         `json:"compile_allocation"`
	FirstRunMs         float64                 `json:"first_run_ms"`
	FirstRunAllocation AllocationStats         `json:"first_run_allocation"`
	Warmup             int                     `json:"warmup"`
	WarmupAllocation   AllocationPerRun        `json:"warmup_allocation"`
	Warm               nodes_bench.BenchRunRes `json:"warm"`
	WarmAllocation     AllocationPerRun        `json:"warm_allocation"`
	Actions            []ActionProfile         `json:"actions,omitempty"`
	CPUProfile         *CPUProfileSummary      `json:"cpu_profile,omitempty"`
	Error              string                  `json:"error,omitempty"`
}

Result separates compilation, first execution, and warm samples.

type Scenario

type Scenario struct {
	Name   string `json:"name"`
	Source string `json:"-"`
	File   string `json:"-"`
}

Scenario is one source file; Name is its portable, suite-relative filter key.

func Discover

func Discover(path string, filters []string) ([]Scenario, error)

Discover recursively reads .nflow files in lexical order. An empty path uses the embedded suite. Explicit paths select a new filesystem root; symlinks within it are rejected, rather than following files outside that suite.

Jump to

Keyboard shortcuts

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