benchmark

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2022 License: MIT Imports: 19 Imported by: 1

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 Benchmark)

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 Benchmark

type Benchmark 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

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 {
	Payload []byte `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"`
	// contains filtered or unexported fields
}

func (*Echo) Descriptor deprecated

func (*Echo) Descriptor() ([]byte, []int)

Deprecated: Use Echo.ProtoReflect.Descriptor instead.

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) String

func (x *Echo) String() string

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) (mgr *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 {
	Allocs uint64 `protobuf:"varint,1,opt,name=Allocs,proto3" json:"Allocs,omitempty"`
	Memory uint64 `protobuf:"varint,2,opt,name=Memory,proto3" json:"Memory,omitempty"`
	// contains filtered or unexported fields
}

func (*MemoryStat) Descriptor deprecated

func (*MemoryStat) Descriptor() ([]byte, []int)

Deprecated: Use MemoryStat.ProtoReflect.Descriptor instead.

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) String

func (x *MemoryStat) String() string

type MemoryStatList

type MemoryStatList struct {
	MemoryStats []*MemoryStat `protobuf:"bytes,1,rep,name=MemoryStats,proto3" json:"MemoryStats,omitempty"`
	// contains filtered or unexported fields
}

func (*MemoryStatList) Descriptor deprecated

func (*MemoryStatList) Descriptor() ([]byte, []int)

Deprecated: Use MemoryStatList.ProtoReflect.Descriptor instead.

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) String

func (x *MemoryStatList) String() string

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 {
	Name        string        `protobuf:"bytes,1,opt,name=Name,proto3" json:"Name,omitempty"`
	TotalOps    uint64        `protobuf:"varint,2,opt,name=TotalOps,proto3" json:"TotalOps,omitempty"`
	TotalTime   int64         `protobuf:"varint,3,opt,name=TotalTime,proto3" json:"TotalTime,omitempty"`
	Throughput  float64       `protobuf:"fixed64,4,opt,name=Throughput,proto3" json:"Throughput,omitempty"`
	LatencyAvg  float64       `protobuf:"fixed64,5,opt,name=LatencyAvg,proto3" json:"LatencyAvg,omitempty"`
	LatencyVar  float64       `protobuf:"fixed64,6,opt,name=LatencyVar,proto3" json:"LatencyVar,omitempty"`
	AllocsPerOp uint64        `protobuf:"varint,7,opt,name=AllocsPerOp,proto3" json:"AllocsPerOp,omitempty"`
	MemPerOp    uint64        `protobuf:"varint,8,opt,name=MemPerOp,proto3" json:"MemPerOp,omitempty"`
	ServerStats []*MemoryStat `protobuf:"bytes,9,rep,name=ServerStats,proto3" json:"ServerStats,omitempty"`
	// 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) Descriptor deprecated

func (*Result) Descriptor() ([]byte, []int)

Deprecated: Use Result.ProtoReflect.Descriptor instead.

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) String

func (x *Result) String() string

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) Descriptor deprecated

func (*StartRequest) Descriptor() ([]byte, []int)

Deprecated: Use StartRequest.ProtoReflect.Descriptor instead.

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 StartResponse

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

func (*StartResponse) Descriptor deprecated

func (*StartResponse) Descriptor() ([]byte, []int)

Deprecated: Use StartResponse.ProtoReflect.Descriptor instead.

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 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) Descriptor deprecated

func (*StopRequest) Descriptor() ([]byte, []int)

Deprecated: Use StopRequest.ProtoReflect.Descriptor instead.

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 TimedMsg

type TimedMsg struct {
	SendTime int64  `protobuf:"varint,1,opt,name=SendTime,proto3" json:"SendTime,omitempty"`
	Payload  []byte `protobuf:"bytes,2,opt,name=payload,proto3" json:"payload,omitempty"`
	// contains filtered or unexported fields
}

func (*TimedMsg) Descriptor deprecated

func (*TimedMsg) Descriptor() ([]byte, []int)

Deprecated: Use TimedMsg.ProtoReflect.Descriptor instead.

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) String

func (x *TimedMsg) String() string

Jump to

Keyboard shortcuts

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