changepoints

package
v0.0.0-...-1c50ca4 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Overview

Package changepoints handles change point detection and analysis. See go/luci-test-variant-analysis-design for details.

Index

Constants

View Source
const RegressionRangeOverlapPrecThreshold = 0.4

RegressionRangeOverlapPrecThreshold decides whether two changepoints can be grouped together. The regression range overlap percentage is calculated by (# of overlapped commits/# of commits in the narrower regression range).

View Source
const TestIDGroupingThreshold = 64

TestIDGroupingThreshold is the threshold to partition changepoints by test ID. TODO: Set this threshold dynamically base on the total number of unique tests in the requested LUCI project and the number of regressions in this period. Because the significance of seeing a gap of 64 in test ID number depends on the above two factors. A possible formula to derive this threshold is (total tests / # of regressions in period) * coefficient.

Variables

This section is empty.

Functions

func Analyze

func Analyze(ctx context.Context, tvs []*rdbpb.TestVariant, payload *taskspb.IngestTestVerdicts, sourcesMap map[string]*pb.Sources, exporter *bqexporter.Exporter) error

Analyze performs change point analyses based on incoming test verdicts. sourcesMap contains the information about the source code being tested.

func CompareTestVariantBranchChangepoint

func CompareTestVariantBranchChangepoint(cpi, cpj *ChangepointRow) bool

CompareTestVariantBranchChangepoint returns whether element at i is smaller than element at j by comparing TestIDNum, VariantHash, RefHash, NominalStartPosition.

func FetchTestVariantBranches

func FetchTestVariantBranches(ctx context.Context) ([]*testvariantbranch.Entry, error)

func GroupChangepoints

func GroupChangepoints(rows []*ChangepointRow) [][]*ChangepointRow

GroupChangepoints returns a 2D array where each row represents a group of changepoints. The grouping result is deterministic, which means same input always results in same groups. The groups are generated with the following steps.

  1. partition changepoints base on test ID
  2. For changepoints in each partition, group base on percentage regression range overlap.

func QueryStatsForClustering

func QueryStatsForClustering(ctx context.Context, tvs []*rdbpb.TestVariant, project string, partitionTime time.Time, sourcesMap map[string]*pb.Sources) ([]*clusteringpb.TestVariantBranch, error)

QueryStatsForClustering reads selected statistics for the test variant branch of nominated test verdicts. The statistics are those tracked in the clustered_failures table.

The result slice will contain result items in 1:1 correspondance to the provided test verdicts (i.e. result[i] corresponds to tvs[i]). If no source information is available for some or all of the verdicts, the corresponding item in the response slice will be nil.

Types

type Analyzer

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

func (*Analyzer) Run

Run runs change point analysis and returns the remaining segment in the input buffer after eviction.

type ChangepointRow

type ChangepointRow struct {
	Project string
	// TestIDNum is the alphabetical ranking of the test ID in this LUCI project.
	TestIDNum   int64
	TestID      string
	VariantHash string
	Variant     bigquery.NullJSON
	// Point to a branch in the source control.
	Ref     *Ref
	RefHash string
	// The verdict unexpected rate before the changepoint.
	UnexpectedVerdictRateBefore float64
	// The verdict unexpected rate after the changepoint.
	UnexpectedVerdictRateAfter float64
	// The current verdict unexpected rate.
	UnexpectedVerdictRateCurrent float64
	// The nominal start hour of the segment after the changepoint.
	StartHour                  time.Time
	LowerBound99th             int64
	UpperBound99th             int64
	NominalStartPosition       int64
	PreviousNominalEndPosition int64
}

ChangepointRow represents a changepoint of a test variant branch.

type CheckPoint

type CheckPoint struct {
	InvocationID        string
	StartingTestID      string
	StartingVariantHash string
}

CheckPoint represents a single row in the TestVariantBranchCheckpoint table.

func (CheckPoint) ToMutation

func (cp CheckPoint) ToMutation() *spanner.Mutation

ToMutation return a spanner Mutation to insert a CheckPoint into

type Client

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

Client to read LUCI Analysis changepoints.

func NewClient

func NewClient(ctx context.Context, gcpProject string) (*Client, error)

NewClient creates a new client for reading changepints.

func (*Client) Close

func (c *Client) Close() error

Close releases any resources held by the client.

func (*Client) ReadChangepoints

func (c *Client) ReadChangepoints(ctx context.Context, project string, week time.Time) ([]*ChangepointRow, error)

ReadChangepoints reads changepoints of a certain week from BigQuery. The week parameter can be at any time of that week. A week is defined by Sunday to Satureday in UTC.

type Gitiles

type Gitiles struct {
	Host    bigquery.NullString
	Project bigquery.NullString
	Ref     bigquery.NullString
}

type Ref

type Ref struct {
	Gitiles *Gitiles
}

Directories

Path Synopsis
Package bayesian implements bayesian analysis for detecting change points.
Package bayesian implements bayesian analysis for detecting change points.
Package bqexporter handles the export of test variant analysis results to BigQuery.
Package bqexporter handles the export of test variant analysis results to BigQuery.
Package bqupdator handles the update of bigquery tables related to changepoint analysis.
Package bqupdator handles the update of bigquery tables related to changepoint analysis.
Package inputbuffer handles the input buffer of change point analysis.
Package inputbuffer handles the input buffer of change point analysis.
Package sources handles sources information.
Package sources handles sources information.
Package testutil contains utility functions for tests.
Package testutil contains utility functions for tests.
Package testvariantbranch handles test variant branch of change point analysis.
Package testvariantbranch handles test variant branch of change point analysis.

Jump to

Keyboard shortcuts

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