twitter

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package twitter generates reproducible workloads derived from the BenchBase Twitter benchmark's transaction weights and SQL procedures.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareResults

func CompareResults(results []Result)

func ResetFixture

func ResetFixture(ctx context.Context, db *sql.DB, cfg Config) error

Types

type Config

type Config struct {
	Kind             WorkloadKind
	Seed             int64
	Workers          int
	WarmupPerWorker  int
	MeasurePerWorker int
	UserCount        int
	TweetsPerUser    int
	ZipfS            float64
	ZipfV            float64
}

func DefaultConfig

func DefaultConfig() Config

type Mode

type Mode string
const (
	ModeRawDB          Mode = "raw_db"
	ModeWrapperNoCache Mode = "wrapper_no_cache"
	ModeLibraryLRU     Mode = "library_lru_cache"
	ModeExactCache     Mode = "exact_cache"
	ModePredictive     Mode = "predictive_cache"
)

type Operation

type Operation string
const (
	OpGetTweet               Operation = "get_tweet"
	OpGetTweetsFromFollowing Operation = "get_tweets_from_following"
	OpGetFollowers           Operation = "get_followers"
	OpGetUserTweets          Operation = "get_user_tweets"
	OpInsertTweet            Operation = "insert_tweet"
	OpGetFollowerIDs         Operation = "get_follower_ids"
	OpGetFollowingIDs        Operation = "get_following_ids"
)

type Result

type Result struct {
	Workload                 WorkloadKind
	Seed                     int64
	Mode                     Mode
	Transactions             int
	ApplicationCalls         uint64
	PostgresQueries          uint64
	Duration                 time.Duration
	TransactionsPerSecond    float64
	CallLatencyP50           time.Duration
	CallLatencyP95           time.Duration
	CacheHits                uint64
	CacheMisses              uint64
	CacheHitRate             float64
	PrefetchAttempts         uint64
	PrefetchAccepted         uint64
	PrefetchHits             uint64
	PrefetchWasted           uint64
	PrefetchHitRate          float64
	PrefetchWasteRate        float64
	PrefetchErrors           uint64
	PrefetchTimeouts         uint64
	PrefetchRejectedUnbound  uint64
	PrefetchRejectedLowConf  uint64
	PrefetchRejectedQueue    uint64
	PrefetchRejectedStale    uint64
	PredictionAccuracyAt1    float64
	PredictionAccuracyAt3    float64
	CacheEntriesBeforeFlush  int64
	CacheBytesBeforeFlush    int64
	TransitionContexts       int64
	BindingRules             int64
	DatabaseQueryReduction   float64
	CacheHitRateLiftVsExact  float64
	PostgresQueryLiftVsExact float64
}

func RunPostgres

func RunPostgres(ctx context.Context, db *sql.DB, workload Workload, mode Mode, cfg RunConfig) (Result, error)

type RunConfig

type RunConfig struct {
	CacheBytes        int64
	ThinkTime         time.Duration
	PrefetchTimeout   time.Duration
	PrefetchWorkers   int
	PrefetchMaxQPS    int
	EventChannelSize  int
	MaxCacheEntrySize int64
	LibraryCacheItems int
}

func DefaultRunConfig

func DefaultRunConfig() RunConfig

type Step

type Step struct {
	Operation Operation
	UserID    int64
	TweetID   int64
	Text      string
}

type Transaction

type Transaction struct {
	Route  string
	UserID int64
	Steps  []Step
}

type WorkerWorkload

type WorkerWorkload struct {
	SessionID string
	Warmup    []Transaction
	Measure   []Transaction
}

type Workload

type Workload struct {
	Kind    WorkloadKind
	Seed    int64
	Workers []WorkerWorkload
}

func Generate

func Generate(cfg Config) Workload

type WorkloadKind

type WorkloadKind string
const (
	WorkloadMix         WorkloadKind = "twitter_mix"
	WorkloadSessionFlow WorkloadKind = "twitter_session_flow"
)

Jump to

Keyboard shortcuts

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