inference

package module
v0.0.0-...-bf0ac87 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2023 License: MIT Imports: 21 Imported by: 8

Documentation

Index

Constants

View Source
const (
	Inf = rate.Limit(math.MaxFloat64)
)

Variables

View Source
var FormatString1 = "%s,%d\n"
View Source
var RedisAIPool = sync.Pool{
	New: func() interface{} {
		return &RedisAI{
			HumanLabel:       make([]byte, 0, 1024),
			HumanDescription: make([]byte, 0, 1024),
			RedisQuery:       make([]byte, 0, 1024),
		}
	},
}

RedisAIPool is a sync.Pool of RedisAI Query types

Functions

func ConvertByteSliceToFloatSlice

func ConvertByteSliceToFloatSlice(transactionDataString []byte) []float32

func ConvertSliceStringToFloat

func ConvertSliceStringToFloat(transactionDataString []string) []float32

func Float32bytes

func Float32bytes(float float32) []byte

func RandReferenceData

func RandReferenceData(n int) []float32

func Uint64frombytes

func Uint64frombytes(bytes []byte) uint64

Types

type BenchmarkRunner

type BenchmarkRunner struct {
	JsonOutFile          string
	MetadataAutobatching int64
	// contains filtered or unexported fields
}

LoadRunner contains the common components for running a inference benchmarking program against a database.

func NewBenchmarkRunner

func NewBenchmarkRunner() *BenchmarkRunner

NewLoadRunner creates a new instance of LoadRunner which is common functionality to be used by inference benchmarker programs

func (*BenchmarkRunner) DatabaseName

func (b *BenchmarkRunner) DatabaseName() string

ModelName returns the name of the database to run queries against

func (*BenchmarkRunner) DebugLevel

func (b *BenchmarkRunner) DebugLevel() int

DebugLevel returns the level of debug messages for this benchmark

func (*BenchmarkRunner) DoPrintResponses

func (b *BenchmarkRunner) DoPrintResponses() bool

DoPrintResponses indicates whether responses for queries should be printed

func (*BenchmarkRunner) GetBufferedReader

func (b *BenchmarkRunner) GetBufferedReader() *bufio.Reader

GetBufferedReader returns the buffered Reader that should be used by the loader

func (*BenchmarkRunner) GetOverallQuantiles

func (b *BenchmarkRunner) GetOverallQuantiles(histogram *hdrhistogram.Histogram) map[string]interface{}

func (*BenchmarkRunner) GetOverallRatesMap

func (l *BenchmarkRunner) GetOverallRatesMap(totalOps uint64, took time.Duration) map[string]interface{}

func (*BenchmarkRunner) IgnoreErrors

func (b *BenchmarkRunner) IgnoreErrors() bool

func (*BenchmarkRunner) Run

func (b *BenchmarkRunner) Run(queryPool *sync.Pool, processorCreateFn ProcessorCreate, rowSizeBytes int, inferencesPerRow int64, metricCollectorFn MetricCollectorCreate)

Run does the bulk of the benchmark execution. It launches a gorountine to track stats, creates workers to process queries, read in the input, execute the queries, and then does cleanup.

func (*BenchmarkRunner) SetLimit

func (b *BenchmarkRunner) SetLimit(limit uint64)

SetLimit changes the number of queries to run, with 0 being all of them

func (*BenchmarkRunner) UseReferenceDataRedis

func (b *BenchmarkRunner) UseReferenceDataRedis() bool

type LoadRunner

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

LoadRunner contains the common components for running a inference benchmarking program against a database.

func NewLoadRunner

func NewLoadRunner() *LoadRunner

NewLoadRunner creates a new instance of LoadRunner which is common functionality to be used by inference benchmarker programs

func (*LoadRunner) GetBufferedReader

func (b *LoadRunner) GetBufferedReader() *bufio.Reader

GetBufferedReader returns the buffered Reader that should be used by the loader

func (*LoadRunner) RunLoad

func (b *LoadRunner) RunLoad(queryPool *sync.Pool, LoaderCreateFn LoaderCreate, rowBenchmarkNBytes int)

Run does the bulk of the benchmark execution. It launches a gorountine to track stats, creates workers to process queries, read in the input, execute the queries, and then does cleanup.

func (*LoadRunner) SetLimit

func (b *LoadRunner) SetLimit(limit uint64)

SetLimit changes the number of queries to run, with 0 being all of them

type Loader

type Loader interface {
	// Init initializes at global state for the Loader, possibly based on its worker number / ID
	Init(workerNum int, wg *sync.WaitGroup)

	// ProcessInferenceQuery handles a given inference and reports its stats
	ProcessLoadQuery(q []byte, debug int) ([]*Stat, uint64, error)
	Close()
}

Loader is an interface that handles the setup of a inference processing worker and executes queries one at a time

type LoaderCreate

type LoaderCreate func() Loader

LoaderCreate is a function that creates a new Loader (called in Run)

type MetricCollector

type MetricCollector interface {
	// CollectRunTimeMetrics asks the specific runner to fetch runtime stats that will then be stored on the results file.
	// Returns the collection timestamp and an interface with all fetched data
	CollectRunTimeMetrics() (int64, interface{}, error)
}

MetricCollector is an interface that handles the metrics collection from the model server

type MetricCollectorCreate

type MetricCollectorCreate func() MetricCollector

type Processor

type Processor interface {
	// Init initializes at global state for the Loader, possibly based on its worker number / ID
	Init(workerNum int, totalWorkers int, wg *sync.WaitGroup, m chan uint64, rs chan uint64)

	// ProcessInferenceQuery handles a given inference and reports its stats
	ProcessInferenceQuery(q []byte, isWarm bool, workerNum int, useReferenceDataRedis bool, useReferenceDataMysql bool, queryNumber int64) ([]*Stat, error)

	// Close forces any work buffered to be sent to the DB being tested prior to going further
	Close()
}

Processor is an interface that handles the setup of a inference processing worker and executes queries one at a time

type ProcessorCreate

type ProcessorCreate func() Processor

LoaderCreate is a function that creates a new Loader (called in Run)

type RedisAI

type RedisAI struct {
	HumanLabel       []byte
	HumanDescription []byte

	RedisQuery []byte
	// contains filtered or unexported fields
}

RedisAI encodes a RedisAI request. This will be serialized for use by the aibench_run_inference_redisai program.

func (*RedisAI) GetID

func (q *RedisAI) GetID() uint64

GetID returns the ID of this Query

func (*RedisAI) HumanDescriptionName

func (q *RedisAI) HumanDescriptionName() []byte

HumanDescriptionName returns the human readable description of this Query

func (*RedisAI) HumanLabelName

func (q *RedisAI) HumanLabelName() []byte

HumanLabelName returns the human readable name of this Query

func (*RedisAI) Release

func (q *RedisAI) Release()

Release resets and returns this Query to its pool

func (*RedisAI) SetID

func (q *RedisAI) SetID(n uint64)

SetID sets the ID for this Query

func (*RedisAI) String

func (q *RedisAI) String() string

String produces a debug-ready description of a Query.

type Stat

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

Stat represents one statistical measurement, typically used to store the latency of a inference (or part of inference).

func GetStat

func GetStat() *Stat

GetStat returns a Stat for use from a pool

func (*Stat) Init

func (s *Stat) Init(label []byte, value int64, totalResults uint64, timedOut bool, query string) *Stat

Init safely initializes a Stat while minimizing heap allocations.

type TestResult

type TestResult struct {

	// Test Configs
	ResultFormatVersion  string `json:"ResultFormatVersion"`
	Limit                uint64 `json:"Limit"`
	MetadataAutobatching int64  `json:"MetadataAutobatching"`
	TensorBatchSize      uint64 `json:"TensorBatchSize"`
	Workers              uint   `json:"Workers"`
	MaxRps               uint64 `json:"MaxRps"`

	// Test Description
	TestDescription string `json:"TestDescription"`

	// DB Spefic Configs
	DBSpecificConfigs map[string]interface{} `json:"DBSpecificConfigs"`

	StartTime      int64 `json:"StartTime`
	EndTime        int64 `json:"EndTime"`
	DurationMillis int64 `json:"DurationMillis"`

	// Totals
	Totals map[string]interface{} `json:"Totals"`

	// Overall Rates
	OverallRates                map[string]interface{} `json:"OverallRates"`
	OverallRatesIncludingWarmup map[string]interface{} `json:"OverallRatesIncludingWarmup"`

	// Overall Quantiles
	OverallQuantiles map[string]interface{} `json:"OverallQuantiles"`

	// Per second ( tick ) client stats
	ClientRunTimeStats map[int64]interface{} `json:"ClientRunTimeStats"`

	// Per second ( tick ) server stats
	ServerRunTimeStats map[int64]interface{} `json:"ServerRunTimeStats"`
}

Jump to

Keyboard shortcuts

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