stats

package
v0.0.0-...-ff61ee7 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2020 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package for keeping statistics about the execution of consensus.

Index

Constants

View Source
const ProfileOut = "testprofile"

Variables

This section is empty.

Functions

func MsgIDCountString

func MsgIDCountString(msgIDCount, minMsgID, maxMsgID []MsgIDInfoCount) string

func SortMsgIDInfoCount

func SortMsgIDInfoCount(sli []MsgIDInfoCount)

Types

type BasicNwStats

type BasicNwStats struct {
	EncryptChannels       bool
	BytesSent             uint64 // The number of bytes sent
	MsgsSent              uint64 // The number of messags sent
	BufferForwardTimeouts uint64 // The number of times passed the timeout on the buffer forwarder
}

BasicNwStats tracks the number of messages and bytes sent

func (*BasicNwStats) Broadcast

func (bs *BasicNwStats) Broadcast(ln int, n int)

Broadcast is called when a messages of size len is sent to n recipiants

func (*BasicNwStats) BufferForwardTimeout

func (bs *BasicNwStats) BufferForwardTimeout()

BufferForwardTimeout is called when a timeout occurs in the buffer forwarder.

func (*BasicNwStats) GetBufferForwardTimeouts

func (bs *BasicNwStats) GetBufferForwardTimeouts() uint64

GetMsgsSent returns the total number of messages sent

func (*BasicNwStats) GetBytesSent

func (bs *BasicNwStats) GetBytesSent() uint64

GetBytesSent returns the total number of bytes sent

func (*BasicNwStats) GetMsgsSent

func (bs *BasicNwStats) GetMsgsSent() uint64

GetMsgsSent returns the total number of messages sent

func (*BasicNwStats) MergeAllNWStats

func (bs *BasicNwStats) MergeAllNWStats(numCons int, others []NwStatsInterface) (MergedNwStats, MergedNwStats)

MergeAllStats merges the stats from the the participants, numCons is the number of consensus instances performed It returns the average stats per node (perProc), and all the stats summed together (merge)

func (*BasicNwStats) NwString

func (bs *BasicNwStats) NwString() string

NwString returns a string "{Bytes sent: %v, Msgs sent: %v}"

func (*BasicNwStats) Send

func (bs *BasicNwStats) Send(ln int)

Send is called when a message of size n is sent to a single recipiant

type BasicStats

type BasicStats struct {
	StatsObj
	Decided     bool
	RecordIndex bool // true if we are keeping stats for this index
	Index       types.ConsensusID
	// contains filtered or unexported fields
}

BasicStats track basic statistics about the consensus.

func (*BasicStats) AddCustomStartTime

func (bs *BasicStats) AddCustomStartTime(t time.Time)

func (*BasicStats) AddFinishRound

func (bs *BasicStats) AddFinishRound(r types.ConsensusRound, decidedNil bool)

func (*BasicStats) AddFinishRoundSet

func (bs *BasicStats) AddFinishRoundSet(r types.ConsensusRound, decisionCount int)

AddFinishRoundSet is called instead of AddFinishRound used for consensus algorithms that decide a set of values

func (*BasicStats) AddForwardState

func (bs *BasicStats) AddForwardState()

AddForwardState is called when the node forwards state to a slow node.

func (*BasicStats) AddParticipationRound

func (bs *BasicStats) AddParticipationRound(r types.ConsensusRound)

func (*BasicStats) AddProgressTimeout

func (bs *BasicStats) AddProgressTimeout()

AddProgressTimeout is called when the consensus times out without making progress.

func (*BasicStats) AddStartTime

func (bs *BasicStats) AddStartTime()

AddStartTime is called each time a new consesnsus instance is started.

func (*BasicStats) BroadcastProposal

func (bs *BasicStats) BroadcastProposal()

BroadcastProposal is called when the node makes a proposal.

func (*BasicStats) CombinedThresholdSig

func (bs *BasicStats) CombinedThresholdSig()

CombinedThresholdSig is called when a threshold signature is combined.

func (*BasicStats) ComputedCoin

func (bs *BasicStats) ComputedCoin()

ComputedCoin is called each time a coin is computed.

func (*BasicStats) CreatedVRF

func (bs *BasicStats) CreatedVRF()

CreatedVRF is called each time a VRF is created.

func (*BasicStats) DiskStore

func (bs *BasicStats) DiskStore(bytes int)

DiskStore is called when storage to disk is done with the number of bytes stored.

func (*BasicStats) DoneRecording

func (bs *BasicStats) DoneRecording()

DoneRecording stops recording the stats.

func (*BasicStats) GetAvgRoundDecide

func (bs *BasicStats) GetAvgRoundDecide() float32

func (*BasicStats) GetAvgRoundParticipation

func (bs *BasicStats) GetAvgRoundParticipation() float32

func (*BasicStats) GetAvgTime

func (bs *BasicStats) GetAvgTime() time.Duration

GetAvgTime returns the average duration for a consensus instance.

func (*BasicStats) GetMaxRoundDecide

func (bs *BasicStats) GetMaxRoundDecide() uint64

func (*BasicStats) GetMaxRoundParticipation

func (bs *BasicStats) GetMaxRoundParticipation() uint64

func (*BasicStats) GetMaxTime

func (bs *BasicStats) GetMaxTime() time.Duration

GetMaxTime returns the longest duration consensus instance.

func (*BasicStats) GetMinRoundDecide

func (bs *BasicStats) GetMinRoundDecide() uint64

func (*BasicStats) GetMinRoundParticipation

func (bs *BasicStats) GetMinRoundParticipation() uint64

func (*BasicStats) GetMinTime

func (bs *BasicStats) GetMinTime() time.Duration

GetMinTime returns the shortest duration consensu instance.

func (*BasicStats) GetRecordedCount

func (bs *BasicStats) GetRecordedCount() (count int)

func (*BasicStats) GetStartAndEndTimes

func (bs *BasicStats) GetStartAndEndTimes() (startTimes, finishTimes []time.Time)

func (*BasicStats) GetSummedTime

func (bs *BasicStats) GetSummedTime() time.Duration

GetSummedTime returns the summed time of all consensus instances.

func (*BasicStats) GetTotalTime

func (bs *BasicStats) GetTotalTime() time.Duration

GetTotalTime returns the duration from the start of the first consensus to the finish of the last consensu.

func (*BasicStats) GetTotalTimeDivNumCons

func (bs *BasicStats) GetTotalTimeDivNumCons() time.Duration

GetTotalTimeDivNumCons returns the total time divided by the number of consensus instances.

func (*BasicStats) IsMember

func (bs *BasicStats) IsMember()

Is member is called when the node finds out it is the member of the consensus.

func (*BasicStats) IsRecordIndex

func (bs *BasicStats) IsRecordIndex() bool

IsRecordIndex returns true if the consensus index of this stats is being recorded.

func (*BasicStats) MemberMsgID

func (bs *BasicStats) MemberMsgID(msgId messages.MsgID)

MemberMsgID is called when the node is a member for the message ID.

func (*BasicStats) MergeAllStats

func (bs *BasicStats) MergeAllStats(to types.TestOptions, sList []MergedStats) (perProc, totals MergedStats)

MergeAllStats takes as input an item for each node that contains its set of merged stats which was the output of MergeLocalStats called on the list of stats for each proc.

func (*BasicStats) MergeLocalStats

func (bs *BasicStats) MergeLocalStats(to types.TestOptions, numCons int) (total MergedStats)

Merge local stats merges the list of stats objects from a single node. There is one stats object for each consensus instance.

func (*BasicStats) New

func (*BasicStats) ProposalForward

func (bs *BasicStats) ProposalForward()

ProposalForwarded is called when a proposal is forwarded

func (*BasicStats) Remove

func (bs *BasicStats) Remove(index types.ConsensusIndex)

Remove is only supported for total ordering

func (*BasicStats) Restart

func (bs *BasicStats) Restart()

Restart is called on restart of failure so it knows to start recording again

func (*BasicStats) SignedItem

func (bs *BasicStats) SignedItem()

SignedItem is called each time consensus signs a message.

func (*BasicStats) StartRecording

func (bs *BasicStats) StartRecording(profileCPU, profileMem bool, testIndex int, testID uint64)

StartRecording starts recording the stats.

func (*BasicStats) String

func (bs *BasicStats) String() string

String outputs the statistics in a human readable format.

func (*BasicStats) ValidatedCoinShare

func (bs *BasicStats) ValidatedCoinShare()

ValidatedCoinShare is call each time a coin share is validated

func (*BasicStats) ValidatedItem

func (bs *BasicStats) ValidatedItem()

ValidatedItem is called each time consensus validates a signature.

func (*BasicStats) ValidatedVRF

func (bs *BasicStats) ValidatedVRF()

ValidatedVRF is called each time a VRF is validated

type ConsMergedNwStats

type ConsMergedNwStats struct {
	ConsNwStats
	MaxConsBytesSent, MaxConsMsgsSent                          uint64
	MinConsBytesSent, MinConsMsgsSent                          uint64
	MaxConsBufferForwardTimeouts, MinConsBufferForwardTimeouts uint64
}

func ConsMergeMergedNWStats

func ConsMergeMergedNWStats(numCons int, items []ConsMergedNwStats) (
	perProc, merge ConsMergedNwStats)

func (*ConsMergedNwStats) ConsNWString

func (cs *ConsMergedNwStats) ConsNWString() string

type ConsNwStats

type ConsNwStats struct {
	ConsEncryptChannels       bool
	ConsBytesSent             uint64 // The number of bytes sent
	ConsMsgsSent              uint64 // The number of messags sent
	ConsBufferForwardTimeouts uint64 // The number of times passed the timeout on the buffer forwarder
}

ConsNwStats tracks the number of messages and bytes sent per consensus instance.

func (*ConsNwStats) ConsBroadcast

func (bs *ConsNwStats) ConsBroadcast(ln int, n int)

Broadcast is called when a messages of size len is sent to n recipiants

func (*ConsNwStats) ConsBufferForwardTimeout

func (bs *ConsNwStats) ConsBufferForwardTimeout()

BufferForwardTimeout is called when a timeout occurs in the buffer forwarder.

func (*ConsNwStats) ConsGetBufferForwardTimeouts

func (bs *ConsNwStats) ConsGetBufferForwardTimeouts() uint64

GetConsMsgsSent returns the total number of messages sent

func (*ConsNwStats) ConsGetBytesSent

func (bs *ConsNwStats) ConsGetBytesSent() uint64

GetConsBytesSent returns the total number of bytes sent

func (*ConsNwStats) ConsGetMsgsSent

func (bs *ConsNwStats) ConsGetMsgsSent() uint64

GetConsMsgsSent returns the total number of messages sent

func (*ConsNwStats) ConsMergeAllNWStats

func (bs *ConsNwStats) ConsMergeAllNWStats(numCons int, items []ConsNwStatsInterface) (
	perProc, merge ConsMergedNwStats)

func (*ConsNwStats) ConsNwString

func (bs *ConsNwStats) ConsNwString() string

NwString returns a string "{Bytes sent: %v, Msgs sent: %v}"

func (*ConsNwStats) ConsSend

func (bs *ConsNwStats) ConsSend(ln int)

Send is called when a message of size n is sent to a single recipiant

type ConsNwStatsInterface

type ConsNwStatsInterface interface {
	ConsBufferForwardTimeout()            // BufferForwardTimeout is called when a timeout occurs in the buffer forwarder.
	ConsGetBufferForwardTimeouts() uint64 // GetMsgsSent returns the total number of messages sent
	ConsBroadcast(len int, n int)         // Broadcast is called when a messages of size len is sent to n recipiants
	ConsSend(len int)                     // Send is called when a message of size n is sent to a single recipiant
	ConsGetBytesSent() uint64             // GetBytesSent returns the total number of bytes sent
	ConsGetMsgsSent() uint64              // GetMsgsSent returns the total number of messages sent
	ConsNwString() string                 // NwString returns a string detailing the statistics in a human readable format
	// MergeAllStats mereges the stats from the the participants, numCons is the number of consensus instances performed
	// It returns the average stats per node (perProc), and all the stats summed togehter (merge)
	ConsMergeAllNWStats(numCons int, items []ConsNwStatsInterface) (perProc, merge ConsMergedNwStats)
}

ConsNwStatsInterface is for tracking statics about network usage for each consensus instance

type MergedNwStats

type MergedNwStats struct {
	BasicNwStats
	MaxBytesSent, MaxMsgsSent                          uint64
	MinBytesSent, MinMsgsSent                          uint64
	MaxBufferForwardTimeouts, MinBufferForwardTimeouts uint64
}

type MergedStats

type MergedStats struct {
	MergedNwStats
	ConsMergedNwStats
	StatsObjBasic
	StartTimes                                                                                                                                                                       []time.Time
	FinishTimes                                                                                                                                                                      []time.Time
	ConsTimes                                                                                                                                                                        []time.Duration
	SinceTimes                                                                                                                                                                       []time.Duration // Time since the previous decided
	MaxSinceTime, MinSinceTime                                                                                                                                                       time.Duration
	MaxConsTime, MinConsTime                                                                                                                                                         time.Duration
	ConsTime                                                                                                                                                                         time.Duration
	MaxValidatedCoin, MaxCoinCreated, MaxDecidedNil, MaxDiskStorage, MaxSigned, MaxValidated, MaxVRFValidated, MaxVRFCreated, MaxRoundDecide, MaxRoundParticipation, MaxThrshCreated uint64
	MinValidatedCoin, MinCoinCreated, MinDecidedNil, MinDiskStorage, MinSigned, MinValidated, MinVRFValidated, MinVRFCreated, MinRoundDecide, MinRoundParticipation, MinThrshCreated uint64
	MaxProgressTimeout, MinProgressTimeout                                                                                                                                           uint64
	MaxProposalForwarded, MinProposalForwarded                                                                                                                                       uint64
	MaxForwardState, MinForwardState                                                                                                                                                 uint64
	MaxMemberCount, MinMemberCount                                                                                                                                                   uint64
	MaxProposalCount, MinProposalCount                                                                                                                                               uint64
	ProposalCount, MemberCount                                                                                                                                                       uint64
	MaxValuesDecidedCount, MinValuesDecidedCount                                                                                                                                     uint64

	ProposalCounts                           []uint64
	MemberCounts                             []uint64
	MsgIDCount, MinMsgIDCount, MaxMsgIDCount []MsgIDInfoCount
	RecordCount                              int
	CpuProfile                               []byte
	StartMemProfile                          []byte
	EndMemProfile                            []byte
}

func MergeStats

func MergeStats(to types.TestOptions, items []MergedStats) (perProc, merge MergedStats)

MergeStats calls `items[0].MergeAllStats(numCons, items)` if len(items) > 0

func (MergedStats) String

func (ms MergedStats) String() string

String outputs the statistics in a human readable format.

type MsgIDInfoCount

type MsgIDInfoCount struct {
	ID    messages.MsgIDInfo
	Count uint64
}

type NwStatsInterface

type NwStatsInterface interface {
	BufferForwardTimeout()            // BufferForwardTimeout is called when a timeout occurs in the buffer forwarder.
	GetBufferForwardTimeouts() uint64 // GetMsgsSent returns the total number of messages sent
	Broadcast(len int, n int)         // Broadcast is called when a messages of size len is sent to n recipiants
	Send(len int)                     // Send is called when a message of size n is sent to a single recipiant
	GetBytesSent() uint64             // GetBytesSent returns the total number of bytes sent
	GetMsgsSent() uint64              // GetMsgsSent returns the total number of messages sent
	NwString() string                 // NwString returns a string detailing the statistics in a human readable format
	// MergeAllStats mereges the stats from the the participants, numCons is the number of consensus instances performed
	// It returns the average stats per node (perProc), and all the stats summed togehter (merge)
	MergeAllNWStats(numCons int, items []NwStatsInterface) (perProc, merge MergedNwStats)
}

NwStatsInterface is for tracking statics about network usage the objects are not called concurrently

type StatsInterface

type StatsInterface interface {
	StatsPrintInterface

	New(index types.ConsensusIndex) StatsInterface
	Remove(index types.ConsensusIndex)                                        // Remove is only supported for total ordering
	StartRecording(profileCPU, profileMem bool, testIndex int, testID uint64) // StartRecording starts recording the stats.
	DoneRecording()                                                           // DoneRecording stops recording the stats.
	AddStartTime()                                                            // AddStartTime is called each time a new consesnsus instance is started.
	AddCustomStartTime(time.Time)                                             // AddStartTime is called each time a new consesnsus instance is started.
	// AddFinishTime()                                                           // AddFinishTime is called time a consensus instance decides.
	SignedItem()                                                 // SignedItem is called each time consensus signs a message.
	ValidatedItem()                                              // ValidatedItem is called each time consensus validates a signature.
	ValidatedCoinShare()                                         // ValidatedCoinShare is call each time a coin share is validated
	ComputedCoin()                                               // ComputedCoin is called each time a coin is computed.
	ValidatedVRF()                                               // ValidatedVRF is called each time a VRF is validated
	CreatedVRF()                                                 // CreatedVRF is called each time a VRF is created.
	String() string                                              // String outputs the statistics in a human readable format.
	AddParticipationRound(r types.ConsensusRound)                // Called when the node participates in a round r
	AddFinishRound(r types.ConsensusRound, decidedNil bool)      // Called when the node decides at round r
	AddFinishRoundSet(r types.ConsensusRound, decisionCount int) // Called instead of AddFinishRound used for consensus algorithms that decide a set of values
	CombinedThresholdSig()                                       // Called when a threshold signature is combined.
	DiskStore(bytes int)                                         // Called when storage to disk is done with the number of bytes stored.
	Restart()                                                    // Called on restart of failure so it knows to start recording again
	IsRecordIndex() bool                                         // IsRecordIndex returns true if the consensus index of this stats is being recorded.
	AddProgressTimeout()                                         // AddProgressTimeout is called when the consensus times out without making progress.
	AddForwardState()                                            // AddForwardState is called when the node forwards state to a slow node.
	BroadcastProposal()                                          // BroadcastProposal is called when the node makes a proposal.
	IsMember()                                                   // Is member is called when the node finds out it is the member of the consensus.
	MemberMsgID(id messages.MsgID)                               // MemberMsgID is called when the node is a member for the message ID.
	ProposalForward()                                            // Called when a proposal is forwarded
	MergeLocalStats(to types.TestOptions, numCons int) (total MergedStats)
	// Merge all stats is a static function that merges the list of stats, and returns the average stats per process, and the total summed stats.
	MergeAllStats(to types.TestOptions, items []MergedStats) (perProc, merge MergedStats)

	NwStatsInterface
	ConsNwStatsInterface
}

StatsInterface is the interface for objects that keep statistics about the consensus.

func GetStatsObject

func GetStatsObject(_ types.ConsType, encryptChannels bool) StatsInterface

type StatsObj

type StatsObj struct {
	ConsNwStats
	StatsObjBasic
}

type StatsObjBasic

type StatsObjBasic struct {
	StartTime          time.Time            // List of the times when consensus instances were started.
	FinishTime         time.Time            // List of the times where consensus instances finished.
	Signed             uint64               // Number of signatures this node has made.
	Validated          uint64               // Number of signature validations this node has performed.
	CoinValidated      uint64               // Number of coin validations
	CoinCreated        uint64               // Number of coins created
	VRFCreated         uint64               // Number of VRFs created
	VRFValidated       uint64               // Number of VRFs validated
	ThrshCreated       uint64               // Number of threshold signatures created
	RoundDecide        uint64               // Round where decision took place
	RoundParticipation uint64               // Last round participated in
	DiskStorage        uint64               // Number of bytes written to disk
	DecidedNil         uint64               //  True if nil was decided
	ValuesDecidedCount uint64               // Number of values decided per consensus
	ProgressTimeout    uint64               // Number of times progress timeout happened.
	ForwardState       uint64               // Number of times state was forwarded due to neighbor timeout.
	Proposal           bool                 // Made a proposal
	ProposalForwarded  uint64               // Number of proposals forwarded
	Member             bool                 // Is a member
	MsgIDMember        []messages.MsgIDInfo // Member for the message ids

	// The following are created from local merging
	ProposalIdxs    []int                  // indices where proposals were made
	MemberIdxs      []int                  // indices where the nodes was a member
	MsgIDMemberIdxs [][]messages.MsgIDInfo // indices per messageid
}

type StatsPrintInterface

type StatsPrintInterface interface {
	GetTotalTime() time.Duration // Sum of all executed time
	GetAvgTime() time.Duration
	GetMaxTime() time.Duration
	GetAvgRoundDecide() float32
	GetMaxRoundDecide() uint64
	GetMinRoundDecide() uint64
	GetSummedTime() time.Duration
	GetTotalTimeDivNumCons() time.Duration
	GetRecordedCount() int
}

Jump to

Keyboard shortcuts

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