Documentation
¶
Overview ¶
Package benchworkload contains the publisher and visitor workloads shared by local runtime tests and deployed benchmarks. Runners own infrastructure.
Index ¶
- Constants
- func Assignment(total, count, index int) int
- func CancellationOnly(err error) bool
- func Origin(size int) http.Handler
- func Payload(size int) []byte
- func PublicURLIndexes(total, count, index int) []int
- func WaitUntil(ctx context.Context, at time.Time) error
- type BandwidthConfig
- type BandwidthResult
- type Coordination
- func (c *Coordination) Get(ctx context.Context, name string, value any) (bool, error)
- func (c *Coordination) Put(ctx context.Context, name string, value any) error
- func (c *Coordination) Wait(ctx context.Context, name string, value any) error
- func (c *Coordination) WorkloadContext(parent context.Context) (context.Context, func())
- type Coordinator
- type HeldStream
- type Histogram
- type Phase
- type PublishedPublicURL
- type PublisherConfig
- type Publishers
- func (g *Publishers) Close(ctx context.Context) (ShutdownResult, error)
- func (g *Publishers) Failures() <-chan error
- func (g *Publishers) Start(ctx context.Context, indexes []int) ([]PublishedPublicURL, error)
- func (g *Publishers) Started() int
- func (g *Publishers) Stop(ctx context.Context, indexes []int) (ShutdownResult, error)
- type RequestResult
- type ShutdownResult
- type Visitor
- func (v Visitor) Bandwidth(ctx context.Context, config BandwidthConfig, urls []string) (BandwidthResult, error)
- func (v Visitor) Hold(parent context.Context, url string) (*HeldStream, error)
- func (v Visitor) Request(parent context.Context, url string, scheduled time.Time) (result RequestResult)
- func (v Visitor) Run(ctx context.Context, config VisitorConfig, urls []string) (VisitorResult, error)
- type VisitorConfig
- type VisitorResult
Constants ¶
const ( BandwidthDownstream = "downstream" BandwidthUpstream = "upstream" BandwidthBidirectional = "bidirectional" )
const RequestTimeout = 5 * time.Second
Variables ¶
This section is empty.
Functions ¶
func Assignment ¶
func CancellationOnly ¶
errors.Is alone would hide a close failure joined with cancellation.
func PublicURLIndexes ¶
Types ¶
type BandwidthConfig ¶
type BandwidthConfig struct {
Direction string `json:"direction"`
Streams int `json:"streams_per_direction"`
BytesPerSecond int64 `json:"bytes_per_second_per_direction"`
Start time.Time `json:"start"`
Duration time.Duration `json:"duration"`
}
BandwidthConfig describes a fixed-rate transfer phase. Streams is the number of streams per active direction.
type BandwidthResult ¶
type BandwidthResult struct {
Direction string `json:"direction"`
StreamsPerDirection int `json:"streams_per_direction"`
TargetBytesPerSecond int64 `json:"target_bytes_per_second_per_direction"`
TargetDuration time.Duration `json:"target_duration"`
StartedAt time.Time `json:"started_at"`
Elapsed time.Duration `json:"elapsed"`
ExpectedUploadBytes int64 `json:"expected_upload_bytes"`
UploadBytes int64 `json:"upload_bytes"`
ExpectedDownloadBytes int64 `json:"expected_download_bytes"`
DownloadBytes int64 `json:"download_bytes"`
UploadBytesPerSecond float64 `json:"upload_bytes_per_second"`
DownloadBytesPerSecond float64 `json:"download_bytes_per_second"`
Failures int `json:"failures"`
FailureSamples []string `json:"failure_samples,omitempty"`
}
BandwidthResult records exact application bytes transferred by a phase.
func (BandwidthResult) Err ¶
func (r BandwidthResult) Err() error
Err reports incomplete or failed transfers.
type Coordination ¶
type Coordination struct {
// contains filtered or unexported fields
}
func NewCoordination ¶
func NewCoordination(endpoint, token string) (*Coordination, error)
func (*Coordination) WorkloadContext ¶
func (c *Coordination) WorkloadContext(parent context.Context) (context.Context, func())
WorkloadContext also stops participants already running a measurement. Stop joins the watcher; cleanup uses a separate context to report its outcome.
type Coordinator ¶
type Coordinator struct {
// contains filtered or unexported fields
}
Coordinator stores immutable run events. The runner owns the phase sequence; participants acknowledge readiness/results under their own event names.
func NewCoordinator ¶
func NewCoordinator() *Coordinator
type HeldStream ¶
type HeldStream struct {
// contains filtered or unexported fields
}
func (*HeldStream) Alive ¶
func (s *HeldStream) Alive() bool
func (*HeldStream) BytesReceived ¶
func (s *HeldStream) BytesReceived() int64
BytesReceived distinguishes ongoing delivery from a stalled, still-open socket.
func (*HeldStream) Close ¶
func (s *HeldStream) Close() error
type Histogram ¶
type Histogram struct {
BoundsMilliseconds []float64 `json:"bounds_milliseconds"`
Counts []uint64 `json:"counts"`
Count uint64 `json:"count"`
SumMilliseconds float64 `json:"sum_milliseconds"`
MinimumMilliseconds float64 `json:"minimum_milliseconds"`
MaximumMilliseconds float64 `json:"maximum_milliseconds"`
}
Histogram counts are cumulative and use the production duration buckets.
func NewHistogram ¶
func (*Histogram) Percentile ¶
type Phase ¶
type Phase struct {
Name string `json:"name"`
Start time.Time `json:"start"`
Duration time.Duration `json:"duration"`
URLs []string `json:"urls"`
Bandwidth *BandwidthConfig `json:"bandwidth,omitempty"`
Combined bool `json:"combined,omitempty"`
Direct bool `json:"direct,omitempty"`
HeldStreams int `json:"held_streams,omitempty"`
CloseHeld bool `json:"close_held,omitempty"`
OpenHeld bool `json:"open_held,omitempty"`
Done bool `json:"done,omitempty"`
}
Phase is sent by the coordinator. Participants do not carry their own copy of the scenario sequence. A zero duration requests correctness probes only.
type PublishedPublicURL ¶
type PublisherConfig ¶
type PublisherConfig struct {
Server, LoginToken, Domain, StateRoot, Target string
HTTPClient *http.Client
RelayTLS *tls.Config
AllowedIPPrefixes []string
// mixed forces alternating QUIC/TLS-TCP cohorts; auto uses production fallback.
Transport string
Parallel int
RequestLimit int
// StartParallel overrides Parallel for activation only; shutdown stays bounded separately.
StartParallel int
ReadyTimeout, StopTimeout time.Duration
DrainTime time.Duration
OnFailure func()
OnActivationFailure func(index int)
Observe func(int, publisher.Event) error
}
type Publishers ¶
type Publishers struct {
// contains filtered or unexported fields
}
func OpenPublishers ¶
func OpenPublishers(ctx context.Context, config PublisherConfig) (_ *Publishers, retErr error)
func (*Publishers) Close ¶
func (g *Publishers) Close(ctx context.Context) (ShutdownResult, error)
func (*Publishers) Failures ¶
func (g *Publishers) Failures() <-chan error
func (*Publishers) Start ¶
func (g *Publishers) Start(ctx context.Context, indexes []int) ([]PublishedPublicURL, error)
Start returns partial readiness on failure. Close must always be called, even after partial activation. Lifecycle methods are called by one coordinator.
func (*Publishers) Started ¶
func (g *Publishers) Started() int
func (*Publishers) Stop ¶
func (g *Publishers) Stop(ctx context.Context, indexes []int) (ShutdownResult, error)
Stop leaves routes running until their bounded shutdown slot is available.
type RequestResult ¶
type RequestResult struct {
URL string `json:"url,omitempty"`
Scheduled time.Time `json:"scheduled"`
Started time.Time `json:"started"`
FirstByte time.Time `json:"first_body_byte,omitzero"`
QueueDelay time.Duration `json:"queue_delay"`
DNS time.Duration `json:"dns"`
Connect time.Duration `json:"connect"`
TLS time.Duration `json:"tls"`
Duration time.Duration `json:"duration"`
Bytes int64 `json:"bytes"`
Error string `json:"error,omitempty"`
Timeout bool `json:"timeout,omitempty"`
QueueExpired bool `json:"queue_expired,omitempty"`
}
type ShutdownResult ¶
type Visitor ¶
func (Visitor) Bandwidth ¶
func (v Visitor) Bandwidth(ctx context.Context, config BandwidthConfig, urls []string) (BandwidthResult, error)
Bandwidth runs paced, byte-verified transfers against the supplied URLs.
func (Visitor) Run ¶
func (v Visitor) Run(ctx context.Context, config VisitorConfig, urls []string) (VisitorResult, error)
type VisitorConfig ¶
type VisitorResult ¶
type VisitorResult struct {
StartedAt time.Time `json:"started_at"`
OfferDuration time.Duration `json:"offer_duration"`
DrainDuration time.Duration `json:"drain_duration"`
Workers int `json:"workers"`
QueueSlots int `json:"queue_slots"`
Rate int `json:"rate"`
Scheduled int `json:"scheduled"`
Started int `json:"started"`
Completed int `json:"completed"`
Successes int `json:"successes"`
Failures int `json:"failures"`
Timeouts int `json:"timeouts"`
Missed int `json:"missed"`
QueueExpired int `json:"queue_expired"`
Bytes int64 `json:"bytes"`
QueueDelay Histogram `json:"queue_delay"`
DNS Histogram `json:"dns"`
Connect Histogram `json:"connect"`
TLS Histogram `json:"tls"`
FirstByte Histogram `json:"first_body_byte"`
Total Histogram `json:"total"`
FailuresSample []RequestResult `json:"failure_samples,omitempty"`
}
func (VisitorResult) Err ¶
func (r VisitorResult) Err() error
func (*VisitorResult) Merge ¶
func (r *VisitorResult) Merge(other VisitorResult) error
func (*VisitorResult) Observe ¶
func (r *VisitorResult) Observe(request RequestResult)
Observe adds one completed or queue-expired request to a local summary.