benchmark

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2025 License: MIT Imports: 19 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var File_benchmark_benchmark_proto protoreflect.FileDescriptor

Functions

func RegisterBenchmarkServer

func RegisterBenchmarkServer(srv *gorums.Server, impl BenchmarkServer)

func StartLocalServers

func StartLocalServers(ctx context.Context, n int, opts ...gorums.ServerOption) []string

StartLocalServers starts benchmark servers locally

Types

type AsyncEcho added in v0.3.0

type AsyncEcho struct {
	*gorums.Async
}

AsyncEcho is a async object for processing replies.

func (*AsyncEcho) Get added in v0.3.0

func (f *AsyncEcho) Get() (*Echo, error)

Get returns the reply and any error associated with the called method. The method blocks until a reply or error is available.

type Bench

type Bench struct {
	Name        string
	Description string
	// contains filtered or unexported fields
}

Bench is a Benchmark with a name and description

func GetBenchmarks

func GetBenchmarks(cfg *Configuration) []Bench

GetBenchmarks returns a list of Benchmarks that can be performed on the configuration

type BenchmarkClient

type BenchmarkClient interface {
	StartServerBenchmark(ctx context.Context, in *StartRequest) (resp *StartResponse, err error)
	StopServerBenchmark(ctx context.Context, in *StopRequest) (resp *Result, err error)
	StartBenchmark(ctx context.Context, in *StartRequest) (resp *StartResponse, err error)
	StopBenchmark(ctx context.Context, in *StopRequest) (resp *MemoryStatList, err error)
	QuorumCall(ctx context.Context, in *Echo) (resp *Echo, err error)
	AsyncQuorumCall(ctx context.Context, in *Echo) *AsyncEcho
	SlowServer(ctx context.Context, in *Echo) (resp *Echo, err error)
	Multicast(ctx context.Context, in *TimedMsg, opts ...gorums.CallOption)
}

BenchmarkClient is the client interface for the Benchmark service.

type BenchmarkServer

type BenchmarkServer interface {
	StartServerBenchmark(ctx gorums.ServerCtx, request *StartRequest) (response *StartResponse, err error)
	StopServerBenchmark(ctx gorums.ServerCtx, request *StopRequest) (response *Result, err error)
	StartBenchmark(ctx gorums.ServerCtx, request *StartRequest) (response *StartResponse, err error)
	StopBenchmark(ctx gorums.ServerCtx, request *StopRequest) (response *MemoryStat, err error)
	QuorumCall(ctx gorums.ServerCtx, request *Echo) (response *Echo, err error)
	AsyncQuorumCall(ctx gorums.ServerCtx, request *Echo) (response *Echo, err error)
	SlowServer(ctx gorums.ServerCtx, request *Echo) (response *Echo, err error)
	Multicast(ctx gorums.ServerCtx, request *TimedMsg)
}

Benchmark is the server-side API for the Benchmark Service

type Configuration

type Configuration struct {
	gorums.RawConfiguration
	// contains filtered or unexported fields
}

A Configuration represents a static set of nodes on which quorum remote procedure calls may be invoked.

func ConfigurationFromRaw added in v0.7.0

func ConfigurationFromRaw(rawCfg gorums.RawConfiguration, qspec QuorumSpec) (*Configuration, error)

ConfigurationFromRaw returns a new Configuration from the given raw configuration and QuorumSpec.

This function may for example be used to "clone" a configuration but install a different QuorumSpec:

cfg1, err := mgr.NewConfiguration(qspec1, opts...)
cfg2 := ConfigurationFromRaw(cfg1.RawConfig, qspec2)

func (Configuration) And added in v0.4.0

And returns a NodeListOption that can be used to create a new configuration combining c and d.

func (*Configuration) AsyncQuorumCall added in v0.3.0

func (c *Configuration) AsyncQuorumCall(ctx context.Context, in *Echo) *AsyncEcho

AsyncQuorumCall asynchronously invokes a quorum call on configuration c and returns a AsyncEcho, which can be used to inspect the quorum call reply and error when available.

func (Configuration) Except added in v0.4.0

Except returns a NodeListOption that can be used to create a new configuration from c without the nodes in rm.

func (*Configuration) Multicast

func (c *Configuration) Multicast(ctx context.Context, in *TimedMsg, opts ...gorums.CallOption)

Multicast is a quorum call invoked on all nodes in configuration c, with the same argument in, and returns a combined result.

func (*Configuration) Nodes

func (c *Configuration) Nodes() []*Node

Nodes returns a slice of each available node. IDs are returned in the same order as they were provided in the creation of the Manager.

NOTE: mutating the returned slice is not supported.

func (*Configuration) QuorumCall added in v0.3.0

func (c *Configuration) QuorumCall(ctx context.Context, in *Echo) (resp *Echo, err error)

benchmarks

func (*Configuration) SlowServer added in v0.3.0

func (c *Configuration) SlowServer(ctx context.Context, in *Echo) (resp *Echo, err error)

SlowServer is a quorum call invoked on all nodes in configuration c, with the same argument in, and returns a combined result.

func (*Configuration) StartBenchmark

func (c *Configuration) StartBenchmark(ctx context.Context, in *StartRequest) (resp *StartResponse, err error)

StartBenchmark is a quorum call invoked on all nodes in configuration c, with the same argument in, and returns a combined result.

func (*Configuration) StartServerBenchmark

func (c *Configuration) StartServerBenchmark(ctx context.Context, in *StartRequest) (resp *StartResponse, err error)

StartServerBenchmark is a quorum call invoked on all nodes in configuration c, with the same argument in, and returns a combined result.

func (*Configuration) StopBenchmark

func (c *Configuration) StopBenchmark(ctx context.Context, in *StopRequest) (resp *MemoryStatList, err error)

StopBenchmark is a quorum call invoked on all nodes in configuration c, with the same argument in, and returns a combined result.

func (*Configuration) StopServerBenchmark

func (c *Configuration) StopServerBenchmark(ctx context.Context, in *StopRequest) (resp *Result, err error)

StopServerBenchmark is a quorum call invoked on all nodes in configuration c, with the same argument in, and returns a combined result.

type Echo

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

func (*Echo) GetPayload

func (x *Echo) GetPayload() []byte

func (*Echo) ProtoMessage

func (*Echo) ProtoMessage()

func (*Echo) ProtoReflect

func (x *Echo) ProtoReflect() protoreflect.Message

func (*Echo) Reset

func (x *Echo) Reset()

func (*Echo) SetPayload added in v0.8.0

func (x *Echo) SetPayload(v []byte)

func (*Echo) String

func (x *Echo) String() string

type Echo_builder added in v0.8.0

type Echo_builder struct {
	Payload []byte
	// contains filtered or unexported fields
}

func (Echo_builder) Build added in v0.8.0

func (b0 Echo_builder) Build() *Echo

type Manager

type Manager struct {
	*gorums.RawManager
}

Manager maintains a connection pool of nodes on which quorum calls can be performed.

func NewManager

func NewManager(opts ...gorums.ManagerOption) *Manager

NewManager returns a new Manager for managing connection to nodes added to the manager. This function accepts manager options used to configure various aspects of the manager.

func (*Manager) NewConfiguration

func (m *Manager) NewConfiguration(opts ...gorums.ConfigOption) (c *Configuration, err error)

NewConfiguration returns a configuration based on the provided list of nodes (required) and an optional quorum specification. The QuorumSpec is necessary for call types that must process replies. For configurations only used for unicast or multicast call types, a QuorumSpec is not needed. The QuorumSpec interface is also a ConfigOption. Nodes can be supplied using WithNodeMap or WithNodeList, or WithNodeIDs. A new configuration can also be created from an existing configuration, using the And, WithNewNodes, Except, and WithoutNodes methods.

func (*Manager) Nodes

func (m *Manager) Nodes() []*Node

Nodes returns a slice of available nodes on this manager. IDs are returned in the order they were added at creation of the manager.

type MemoryStat

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

func (*MemoryStat) GetAllocs

func (x *MemoryStat) GetAllocs() uint64

func (*MemoryStat) GetMemory

func (x *MemoryStat) GetMemory() uint64

func (*MemoryStat) ProtoMessage

func (*MemoryStat) ProtoMessage()

func (*MemoryStat) ProtoReflect

func (x *MemoryStat) ProtoReflect() protoreflect.Message

func (*MemoryStat) Reset

func (x *MemoryStat) Reset()

func (*MemoryStat) SetAllocs added in v0.8.0

func (x *MemoryStat) SetAllocs(v uint64)

func (*MemoryStat) SetMemory added in v0.8.0

func (x *MemoryStat) SetMemory(v uint64)

func (*MemoryStat) String

func (x *MemoryStat) String() string

type MemoryStatList

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

func (*MemoryStatList) GetMemoryStats

func (x *MemoryStatList) GetMemoryStats() []*MemoryStat

func (*MemoryStatList) ProtoMessage

func (*MemoryStatList) ProtoMessage()

func (*MemoryStatList) ProtoReflect

func (x *MemoryStatList) ProtoReflect() protoreflect.Message

func (*MemoryStatList) Reset

func (x *MemoryStatList) Reset()

func (*MemoryStatList) SetMemoryStats added in v0.8.0

func (x *MemoryStatList) SetMemoryStats(v []*MemoryStat)

func (*MemoryStatList) String

func (x *MemoryStatList) String() string

type MemoryStatList_builder added in v0.8.0

type MemoryStatList_builder struct {
	MemoryStats []*MemoryStat
	// contains filtered or unexported fields
}

func (MemoryStatList_builder) Build added in v0.8.0

type MemoryStat_builder added in v0.8.0

type MemoryStat_builder struct {
	Allocs uint64
	Memory uint64
	// contains filtered or unexported fields
}

func (MemoryStat_builder) Build added in v0.8.0

func (b0 MemoryStat_builder) Build() *MemoryStat

type Node

type Node struct {
	*gorums.RawNode
}

Node encapsulates the state of a node on which a remote procedure call can be performed.

type Options

type Options struct {
	Concurrent int           // Number of concurrent calls
	Duration   time.Duration // Duration of benchmark
	MaxAsync   int           // Max async calls at once
	NumNodes   int           // Number of nodes to include in configuration
	Payload    int           // Size of message payload
	QuorumSize int           // Number of messages to wait for
	Warmup     time.Duration // Warmup time
	Remote     bool          // Whether the servers are remote (true) or local (false)
}

Options controls different options for the benchmarks

type QSpec

type QSpec struct {
	CfgSize int
	QSize   int
}

QSpec is the quorum specification object for the benchmark

func (*QSpec) AsyncQuorumCallQF added in v0.3.0

func (qspec *QSpec) AsyncQuorumCallQF(_ *Echo, replies map[uint32]*Echo) (*Echo, bool)

AsyncQuorumCallQF is the quorum function for the AsyncQuorumCall quorumcall

func (*QSpec) QuorumCallQF added in v0.3.0

func (qspec *QSpec) QuorumCallQF(_ *Echo, replies map[uint32]*Echo) (*Echo, bool)

QuorumCallQF is the quorum function for the QuorumCall quorumcall

func (*QSpec) SlowServerQF added in v0.3.0

func (qspec *QSpec) SlowServerQF(_ *Echo, replies map[uint32]*Echo) (*Echo, bool)

SlowServerQF is the quorum function for the SlowServer quorumcall

func (*QSpec) StartBenchmarkQF

func (qspec *QSpec) StartBenchmarkQF(_ *StartRequest, replies map[uint32]*StartResponse) (*StartResponse, bool)

StartBenchmarkQF is the quorum function for the StartBenchmark quorumcall. It requires a response from all nodes.

func (*QSpec) StartServerBenchmarkQF

func (qspec *QSpec) StartServerBenchmarkQF(_ *StartRequest, replies map[uint32]*StartResponse) (*StartResponse, bool)

StartServerBenchmarkQF is the quorum function for the StartServerBenchmark quorumcall. It requires a response from all nodes.

func (*QSpec) StopBenchmarkQF

func (qspec *QSpec) StopBenchmarkQF(_ *StopRequest, replies map[uint32]*MemoryStat) (*MemoryStatList, bool)

StopBenchmarkQF is the quorum function for the StopBenchmark quorumcall. It requires a response from all nodes.

func (*QSpec) StopServerBenchmarkQF

func (qspec *QSpec) StopServerBenchmarkQF(_ *StopRequest, replies map[uint32]*Result) (*Result, bool)

StopServerBenchmarkQF is the quorum function for the StopServerBenchmark quorumcall. It requires a response from all nodes.

type QuorumSpec

type QuorumSpec interface {
	gorums.ConfigOption

	// StartServerBenchmarkQF is the quorum function for the StartServerBenchmark
	// quorum call method. The in parameter is the request object
	// supplied to the StartServerBenchmark method at call time, and may or may not
	// be used by the quorum function. If the in parameter is not needed
	// you should implement your quorum function with '_ *StartRequest'.
	StartServerBenchmarkQF(in *StartRequest, replies map[uint32]*StartResponse) (*StartResponse, bool)

	// StopServerBenchmarkQF is the quorum function for the StopServerBenchmark
	// quorum call method. The in parameter is the request object
	// supplied to the StopServerBenchmark method at call time, and may or may not
	// be used by the quorum function. If the in parameter is not needed
	// you should implement your quorum function with '_ *StopRequest'.
	StopServerBenchmarkQF(in *StopRequest, replies map[uint32]*Result) (*Result, bool)

	// StartBenchmarkQF is the quorum function for the StartBenchmark
	// quorum call method. The in parameter is the request object
	// supplied to the StartBenchmark method at call time, and may or may not
	// be used by the quorum function. If the in parameter is not needed
	// you should implement your quorum function with '_ *StartRequest'.
	StartBenchmarkQF(in *StartRequest, replies map[uint32]*StartResponse) (*StartResponse, bool)

	// StopBenchmarkQF is the quorum function for the StopBenchmark
	// quorum call method. The in parameter is the request object
	// supplied to the StopBenchmark method at call time, and may or may not
	// be used by the quorum function. If the in parameter is not needed
	// you should implement your quorum function with '_ *StopRequest'.
	StopBenchmarkQF(in *StopRequest, replies map[uint32]*MemoryStat) (*MemoryStatList, bool)

	// QuorumCallQF is the quorum function for the QuorumCall
	// quorum call method. The in parameter is the request object
	// supplied to the QuorumCall method at call time, and may or may not
	// be used by the quorum function. If the in parameter is not needed
	// you should implement your quorum function with '_ *Echo'.
	QuorumCallQF(in *Echo, replies map[uint32]*Echo) (*Echo, bool)

	// AsyncQuorumCallQF is the quorum function for the AsyncQuorumCall
	// asynchronous quorum call method. The in parameter is the request object
	// supplied to the AsyncQuorumCall method at call time, and may or may not
	// be used by the quorum function. If the in parameter is not needed
	// you should implement your quorum function with '_ *Echo'.
	AsyncQuorumCallQF(in *Echo, replies map[uint32]*Echo) (*Echo, bool)

	// SlowServerQF is the quorum function for the SlowServer
	// quorum call method. The in parameter is the request object
	// supplied to the SlowServer method at call time, and may or may not
	// be used by the quorum function. If the in parameter is not needed
	// you should implement your quorum function with '_ *Echo'.
	SlowServerQF(in *Echo, replies map[uint32]*Echo) (*Echo, bool)
}

QuorumSpec is the interface of quorum functions for Benchmark.

type Result

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

func RunBenchmarks

func RunBenchmarks(benchRegex *regexp.Regexp, options Options, cfg *Configuration) ([]*Result, error)

RunBenchmarks runs all the benchmarks that match the given regex with the given options

func (*Result) Format

func (r *Result) Format() string

Format returns a tab formatted string representation of the result

func (*Result) GetAllocsPerOp

func (x *Result) GetAllocsPerOp() uint64

func (*Result) GetLatencyAvg

func (x *Result) GetLatencyAvg() float64

func (*Result) GetLatencyVar

func (x *Result) GetLatencyVar() float64

func (*Result) GetMemPerOp

func (x *Result) GetMemPerOp() uint64

func (*Result) GetName

func (x *Result) GetName() string

func (*Result) GetServerStats

func (x *Result) GetServerStats() []*MemoryStat

func (*Result) GetThroughput

func (x *Result) GetThroughput() float64

func (*Result) GetTotalOps

func (x *Result) GetTotalOps() uint64

func (*Result) GetTotalTime

func (x *Result) GetTotalTime() int64

func (*Result) ProtoMessage

func (*Result) ProtoMessage()

func (*Result) ProtoReflect

func (x *Result) ProtoReflect() protoreflect.Message

func (*Result) Reset

func (x *Result) Reset()

func (*Result) SetAllocsPerOp added in v0.8.0

func (x *Result) SetAllocsPerOp(v uint64)

func (*Result) SetLatencyAvg added in v0.8.0

func (x *Result) SetLatencyAvg(v float64)

func (*Result) SetLatencyVar added in v0.8.0

func (x *Result) SetLatencyVar(v float64)

func (*Result) SetMemPerOp added in v0.8.0

func (x *Result) SetMemPerOp(v uint64)

func (*Result) SetName added in v0.8.0

func (x *Result) SetName(v string)

func (*Result) SetServerStats added in v0.8.0

func (x *Result) SetServerStats(v []*MemoryStat)

func (*Result) SetThroughput added in v0.8.0

func (x *Result) SetThroughput(v float64)

func (*Result) SetTotalOps added in v0.8.0

func (x *Result) SetTotalOps(v uint64)

func (*Result) SetTotalTime added in v0.8.0

func (x *Result) SetTotalTime(v int64)

func (*Result) String

func (x *Result) String() string

type Result_builder added in v0.8.0

type Result_builder struct {
	Name        string
	TotalOps    uint64
	TotalTime   int64
	Throughput  float64
	LatencyAvg  float64
	LatencyVar  float64
	AllocsPerOp uint64
	MemPerOp    uint64
	ServerStats []*MemoryStat
	// contains filtered or unexported fields
}

func (Result_builder) Build added in v0.8.0

func (b0 Result_builder) Build() *Result

type Server

type Server struct {
	*gorums.Server
	// contains filtered or unexported fields
}

Server is a unified server for both ordered and unordered methods

func NewBenchServer added in v0.3.0

func NewBenchServer(opts ...gorums.ServerOption) *Server

NewBenchServer returns a new benchmark server

type StartRequest

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

func (*StartRequest) ProtoMessage

func (*StartRequest) ProtoMessage()

func (*StartRequest) ProtoReflect

func (x *StartRequest) ProtoReflect() protoreflect.Message

func (*StartRequest) Reset

func (x *StartRequest) Reset()

func (*StartRequest) String

func (x *StartRequest) String() string

type StartRequest_builder added in v0.8.0

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

func (StartRequest_builder) Build added in v0.8.0

func (b0 StartRequest_builder) Build() *StartRequest

type StartResponse

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

func (*StartResponse) ProtoMessage

func (*StartResponse) ProtoMessage()

func (*StartResponse) ProtoReflect

func (x *StartResponse) ProtoReflect() protoreflect.Message

func (*StartResponse) Reset

func (x *StartResponse) Reset()

func (*StartResponse) String

func (x *StartResponse) String() string

type StartResponse_builder added in v0.8.0

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

func (StartResponse_builder) Build added in v0.8.0

type Stats

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

Stats records and processes the raw data of a benchmark

func (*Stats) AddLatency

func (s *Stats) AddLatency(l time.Duration)

AddLatency adds a latency measurement

func (*Stats) Clear

func (s *Stats) Clear()

Clear zeroes out the stats

func (*Stats) End

func (s *Stats) End()

End records the end time and memory stats

func (*Stats) GetResult

func (s *Stats) GetResult() *Result

GetResult computes and returns the result of the benchmark

func (*Stats) Start

func (s *Stats) Start()

Start records the start time and memory stats

type StopRequest

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

func (*StopRequest) ProtoMessage

func (*StopRequest) ProtoMessage()

func (*StopRequest) ProtoReflect

func (x *StopRequest) ProtoReflect() protoreflect.Message

func (*StopRequest) Reset

func (x *StopRequest) Reset()

func (*StopRequest) String

func (x *StopRequest) String() string

type StopRequest_builder added in v0.8.0

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

func (StopRequest_builder) Build added in v0.8.0

func (b0 StopRequest_builder) Build() *StopRequest

type TimedMsg

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

func (*TimedMsg) GetPayload

func (x *TimedMsg) GetPayload() []byte

func (*TimedMsg) GetSendTime

func (x *TimedMsg) GetSendTime() int64

func (*TimedMsg) ProtoMessage

func (*TimedMsg) ProtoMessage()

func (*TimedMsg) ProtoReflect

func (x *TimedMsg) ProtoReflect() protoreflect.Message

func (*TimedMsg) Reset

func (x *TimedMsg) Reset()

func (*TimedMsg) SetPayload added in v0.8.0

func (x *TimedMsg) SetPayload(v []byte)

func (*TimedMsg) SetSendTime added in v0.8.0

func (x *TimedMsg) SetSendTime(v int64)

func (*TimedMsg) String

func (x *TimedMsg) String() string

type TimedMsg_builder added in v0.8.0

type TimedMsg_builder struct {
	SendTime int64
	Payload  []byte
	// contains filtered or unexported fields
}

func (TimedMsg_builder) Build added in v0.8.0

func (b0 TimedMsg_builder) Build() *TimedMsg

Jump to

Keyboard shortcuts

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