glutton

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Overview

Package glutton implements the benchmarking workload served by cmd/benchmarking/glutton: an API for consuming RAM, disk, and file descriptors, and for gossiping with other glutton instances, over either gRPC or protobuf-over-HTTP. See internal/proto/glutton/glutton.proto.

Index

Constants

View Source
const (
	ModeGRPC = "grpc"
	ModeHTTP = "http"
)

Wire modes the main listener can serve, selected by the binary's --mode flag.

View Source
const (
	ReadyzRoute    = "/readyz"
	PingRoute      = "/ping"
	WriteDiskRoute = "/writedisk"
	ReadDiskRoute  = "/readdisk"
	WriteRAMRoute  = "/writeram"
	ReadRAMRoute   = "/readram"
	BurnCPURoute   = "/burncpu"
	IngestRoute    = "/ingest"
	UseCPURoute    = "/usecpu"
)

Routes the HTTP-mode mux serves. ReadyzRoute is served in both modes: ateom blocks RestoreWorkload until it answers 200, so ResumeActor cannot report success before the listener is reachable. The fake in ./fake aliases these, which is what keeps the stand-in and the real mux from drifting apart.

View Source
const Name = "glutton"

Name is the workload's identity to the telemetry SDK: the tracer and meter scope, and the service name the binary reports. Instrument names are written out in full at each call site so they match docs/metrics/registry/metrics.yaml literally.

Variables

This section is empty.

Functions

func Handler

func Handler(mode string, svc *Service) (http.Handler, error)

Handler builds the request handler for the given wire mode. ModeGRPC serves gRPC alongside the wakeup probe on a single listener; ModeHTTP serves the protobuf-over-HTTP route table. An unknown mode comes back as an error so the caller decides how to fail.

func NewServer

func NewServer(handler http.Handler) *http.Server

NewServer enables unencrypted HTTP/2 so gRPC works on the plaintext listener, alongside HTTP/1.1 for the wakeup probe.

Types

type Option added in v0.5.0

type Option func(*Service)

Option configures a Service.

func WithSyncWrites added in v0.5.0

func WithSyncWrites() Option

WithSyncWrites makes WriteDisk fsync each file before it returns, so the measured write includes the flush to the backing volume.

func WithWritableReadyz added in v0.5.0

func WithWritableReadyz() Option

WithWritableReadyz makes /readyz fail until the data dir is writable, so ResumeActor waits for an external volume mount before the actor takes load.

type Service

type Service struct {
	gluttonpb.UnimplementedGluttonServer
	// contains filtered or unexported fields
}

func New

func New(dir string, opts ...Option) (*Service, error)

New constructs a Service storing WriteDisk files under dir and registers its otel instruments. The caller is responsible for creating dir and for calling Close to stop any running gossip goroutines.

func (*Service) BurnCPU added in v0.4.0

BurnCPU spins the requested number of goroutines in a sha256 loop until the wall-clock duration elapses. The iteration count in the response keeps the work observable. Deliberately unsynchronized with s.mu: burning must not block the other RPCs.

func (*Service) Close

func (s *Service) Close()

Close cancels every running gossip goroutine and waits for them to exit, then tears down any running CPU load pool.

func (*Service) Gossip

Sends network traffic to a peer glutton. Messages will be sent on regular intervals separated by delay_ms.

func (*Service) Ingest added in v0.4.0

Ingest writes the caller-supplied payload to a file under the data dir. The payload crossed the network to get here, which is the point: WriteDisk generates its bytes locally, Ingest models a download arriving through the actor's ingress path before it hits disk.

func (*Service) OpenFD

Make sure it has the specified number of file descriptors open. It will open or close file descriptors to hit the desired count (note this count is in addition to the other FDs needed to run the process).

func (*Service) Ping

Receive a ping request, echoing the same response back.

func (*Service) ReadDisk

func (*Service) ReadRAM

Walk RAM previously written by WriteRAM, reading one byte per page so every touched page must be resident before the response returns. After a demand-paged restore this converts restore-time laziness into measurable read latency.

func (*Service) UseCPU added in v0.4.0

UseCPU replaces the currently-running CPU load pool. A num_cores of 0 stops all CPU load. See UseCPURequest for how (num_cores, duty_cycle, cycle_length_ms, cap_at_gomaxprocs) shape the load.

func (*Service) WriteDisk

Write to disk using the specified mode. Data written will be random bytes.

func (*Service) WriteRAM

Write to RAM, either overwriting previously-used RAM or allocating additional RAM per request instructions. Data written will be random bytes.

Directories

Path Synopsis
Package fake provides an httptest-backed stand-in for a glutton actor.
Package fake provides an httptest-backed stand-in for a glutton actor.

Jump to

Keyboard shortcuts

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