analysis

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2017 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package analysis implements accumulation of individual operations into summary statistics.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyReport

type KeyReport struct {
	// cache key
	Name string
	// size of the cache value in bytes
	Size int
	// number of requests for this cache key
	RequestsEstimate int
	// amount of bandwidth consumed by traffic for this cache key in bytes
	TrafficEstimate int
}

KeyReport contains activity information for a single cache key.

type Pool

type Pool struct {
	// A Logger instance for debugging.  No logging is done if nil.
	Logger log.Logger
	// contains filtered or unexported fields
}

Pool tracks datastore activity by hashing inputs to fixed workers. The number of workers is determined when the Pool is created. The implementation prioritizes responsiveness over consistency, and data is dropped if the rate of input is too high to be handled by the Pool.

func New

func New(numWorkers, reportSize int) *Pool

New returns a new Pool.

numWorkers determines the number of workers to hotlists to create. More workers gives more potential parallelism and performance, but increased memory consumption.

reportSize determines the number of entries returned from Report.

func (*Pool) HandleEvents

func (p *Pool) HandleEvents(evts []model.Event)

HandleEvents adds records for a set of datastore operations to the Pool.

The events will be dispatched to their assigned workers. If a worker is overloaded, all inputs for that worker will be discarded and statistics for this Pool updated to reflect the lost data.

HandleEvents is threadsafe.

func (*Pool) Report

func (p *Pool) Report(shouldReset bool) Report

Report returns a summary of activity recorded in this Pool since the last call to Reset.

The returned report does not represent a consistent snapshot since information is collected from workers concurrent with new information coming in.

If shouldReset is true, then a best effort will be made to clear data in the Pool while building the report. Since clearing data is an asynchronous operation across the workers in the pool, some information may be carried over between successive reports, and some data may be lost entirely.

func (*Pool) Reset

func (p *Pool) Reset()

Reset clears all recorded activity from this Pool. This operation is asynchronous, and may still be in progress when Reset returns. New data added by calling HandleGetResponse after Reset returns may be lost, and results from Report immediately after a call to Reset may still contain some information recorded before the call to Reset.

func (*Pool) SetFilterPattern

func (p *Pool) SetFilterPattern(pattern string) error

SetFilterPattern sets an RE2 pattern for future data points. Only operations on keys matching pattern will have statistics collected. Setting a new filter invalidates existing results, so current statistics are cleared before returning. If pattern is the empty string statistics are collected for all keys.

func (*Pool) Stats

func (p *Pool) Stats() Stats

Stats returns a record of total activity reported to this Pool, including input that was dropped due to not keeping up.

type Report

type Report struct {
	// when this report was generated
	Timestamp time.Time
	// key reports in descending order by TrafficEstimate
	Keys []KeyReport
}

Report represents key activity submitted to a Pool since the last call to Reset.

func (Report) Len

func (r Report) Len() int

Len implements sort.Interface for Report.

func (Report) Less

func (r Report) Less(i, j int) bool

Less implements sort.Interface for Report, sorting KeyReports in descending order by TrafficEstimate.

func (Report) Swap

func (r Report) Swap(i, j int)

Swap implements sort.Interface for Report.

type Stats

type Stats struct {
	// number of events sent to HandleEvents that were recorded
	EventsHandled int64
	// number of events sent to HandleEvents that were discarded
	EventsDropped int64
}

Stats contains performance metrics for a Pool.

Jump to

Keyboard shortcuts

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