timeout

package
v0.34.0-crescendo-prev... Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: AGPL-3.0 Imports: 4 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = NewDefaultConfig()

Functions

This section is empty.

Types

type Config

type Config struct {
	// MinReplicaTimeout is the minimum the timeout can decrease to [MILLISECONDS]
	MinReplicaTimeout float64
	// MaxReplicaTimeout is the maximum value the timeout can increase to [MILLISECONDS]
	MaxReplicaTimeout float64
	// TimeoutAdjustmentFactor: MULTIPLICATIVE factor for increasing timeout when view
	// change was triggered by a TC (unhappy path) or decreasing the timeout on progress
	TimeoutAdjustmentFactor float64
	// HappyPathMaxRoundFailures is the number of rounds without progress where we still consider being
	// on hot path of execution. After exceeding this value we will start increasing timeout values.
	HappyPathMaxRoundFailures uint64
	// MaxTimeoutObjectRebroadcastInterval is the maximum value for timeout object rebroadcast interval [MILLISECONDS]
	MaxTimeoutObjectRebroadcastInterval float64
}

Config contains the configuration parameters for a Truncated Exponential Backoff, as implemented by the `timeout.Controller`

  • On timeout: increase timeout by multiplicative factor `TimeoutAdjustmentFactor`. This results in exponentially growing timeout duration on multiple subsequent timeouts.
  • On progress: decrease timeout by multiplicative factor `TimeoutAdjustmentFactor.

Config is implemented such that it can be passed by value, while still supporting updates of `BlockRateDelayMS` at runtime (all configs share the same memory holding `BlockRateDelayMS`).

func NewConfig

func NewConfig(minReplicaTimeout time.Duration, maxReplicaTimeout time.Duration, timeoutAdjustmentFactor float64, happyPathMaxRoundFailures uint64, maxRebroadcastInterval time.Duration) (Config, error)

NewConfig creates a new TimoutConfig.

  • minReplicaTimeout: minimal timeout value for replica round [Milliseconds] Consistency requirement: must be non-negative
  • maxReplicaTimeout: maximal timeout value for replica round [Milliseconds] Consistency requirement: must be non-negative and cannot be smaller than minReplicaTimeout
  • timeoutAdjustmentFactor: multiplicative factor for adjusting timeout duration Consistency requirement: must be strictly larger than 1
  • happyPathMaxRoundFailures: number of successive failed rounds after which we will start increasing timeouts
  • blockRateDelay: a delay to delay the proposal broadcasting [Milliseconds] Consistency requirement: must be non-negative

Returns `model.ConfigurationError` is any of the consistency requirements is violated.

func NewDefaultConfig

func NewDefaultConfig() Config

NewDefaultConfig returns a default timeout configuration. We explicitly provide a method here, which demonstrates in-code how to compute standard values from some basic quantities.

type Controller

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

Controller implements the following truncated exponential backoff:

duration = t_min * min(b ^ ((r-k) * θ(r-k)), t_max)

For practical purpose we will transform this formula into:

duration(r) = t_min * b ^ (min((r-k) * θ(r-k)), c), where c = log_b (t_max / t_min).

In described formula:

  k - is number of rounds we expect during hot path, after failing this many rounds,
      we will start increasing timeouts.
  b - timeout increase factor
  r - failed rounds counter
  θ - Heaviside step function
	 t_min/t_max - minimum/maximum round duration

By manipulating `r` after observing progress or lack thereof, we are achieving exponential increase/decrease of round durations.

  • on timeout: increase number of failed rounds, this results in exponential growing round duration on multiple subsequent timeouts, after exceeding k.
  • on progress: decrease number of failed rounds, this results in exponential decrease of round duration.

func NewController

func NewController(timeoutConfig Config) *Controller

NewController creates a new Controller. Note that the input Config is implemented such that it can be passed by value, while still supporting updates of `BlockRateDelayMS` at runtime (all configs share the same memory holding `BlockRateDelayMS`).

func (*Controller) Channel

func (t *Controller) Channel() <-chan time.Time

Channel returns a channel that will receive the specific timeout. A new channel is created on each call of `StartTimeout`. Returns closed channel if no timer has been started.

func (*Controller) OnProgressBeforeTimeout

func (t *Controller) OnProgressBeforeTimeout()

OnProgressBeforeTimeout indicates to the Controller that progress was made _before_ the timeout was reached

func (*Controller) OnTimeout

func (t *Controller) OnTimeout()

OnTimeout indicates to the Controller that a view change was triggered by a TC (unhappy path).

func (*Controller) StartTimeout

func (t *Controller) StartTimeout(ctx context.Context, view uint64) model.TimerInfo

StartTimeout starts the timeout of the specified type and returns the timer info

Jump to

Keyboard shortcuts

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