benchapp

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package benchapp holds the corpus the browser sync benchmarks measure against: the syncplane.bench.v1 issue tracker, its size tiers, and a deterministic generator that seeds a workspace server-side.

It is split out of cmd/benchserver so the tier definitions are importable by anything that wants to reason about corpus size without spawning a server.

Determinism

A benchmark is only comparable against its own history if the corpus is identical run to run, so generation is a pure function of (tier, seed): single-goroutine, seeded PRNG, no clock, no map iteration in a position that reaches a row. Change GeneratorVersion whenever a seeded database changes — the harness folds it into the cache fingerprint, so a corpus seeded by an older version is regenerated rather than silently compared against.

Index

Constants

View Source
const (
	SearchRareTerm   = "zygote"
	SearchMidTerm    = "quasar"
	SearchCommonTerm = "telemetry"
	// RareTermRows is fixed across tiers, so the rare search returns the same
	// rows from a thousand-row corpus and from a half-million-row one.
	RareTermRows = 10
	MidTermPer   = 100
)

The search markers, and how many rows carry them. Exported because the benchmark specs search for them by name and assert the row counts they get back: a search whose result set moved is measuring a different query.

View Source
const (
	// SearchSizeIssues is the number of issues SeedSearchSize writes.
	SearchSizeIssues = 2000
	// SearchSizeVocab is the number of distinct words the bodies draw from.
	SearchSizeVocab = 20000
	// SearchSizeBodyWords is the length of one issue body, in words.
	SearchSizeBodyWords = 300
	// SearchSizeTitleWords is the length of one issue title, in words.
	SearchSizeTitleWords = 8
	// SearchSizeProjects and SearchSizeUsers are the rows the issues refer to.
	SearchSizeProjects = 20
	SearchSizeUsers    = 50
)

The text-heavy search corpus. Its parameters and its PRNG draws are the same as the SQLite size fixture in engine/storage/sqlitestore/searchsize_test.go, so a title or a body here is word for word the one that fixture writes, and a client-side size compares with the server-side one. Only the keys differ: these are shaped like client ids (see SearchSizeKey).

View Source
const GeneratorVersion = 3

GeneratorVersion changes whenever a seeded database does — its rows, and the server-side state the seeder leaves behind, such as which indexes are built. It is the cache key for a seeded database: bump it and every cached corpus is regenerated.

Variables

View Source
var SearchSizeWorkspace = SearchSizeKey(0, 0)

SearchSizeWorkspace is the workspace SeedSearchSize writes into. It has the shape of a client id, the same as the row keys.

View Source
var TierNames = []string{"s", "m", "l", "xl"}

TierNames lists the tiers smallest first — a stable order for seeding and reporting, which ranging over the map would not give.

View Source
var Tiers = map[string]Tier{
	"s": {
		Name: "s", Approx: 1_000,
		Projects: 5, Users: 25, Labels: 12,
		Issues: 500, Comments: 300, Notes: 10, Flats: 150,
		NoteChars: 2_000, IssueBodyChars: 160,
	},
	"m": {
		Name: "m", Approx: 10_000,
		Projects: 12, Users: 100, Labels: 20,
		Issues: 5_000, Comments: 3_000, Notes: 50, Flats: 1_800,
		NoteChars: 4_000, IssueBodyChars: 160,
	},
	"l": {
		Name: "l", Approx: 100_000,
		Projects: 40, Users: 400, Labels: 30,
		Issues: 50_000, Comments: 30_000, Notes: 200, Flats: 19_000,
		NoteChars: 4_000, IssueBodyChars: 160,
	},
	"xl": {
		Name: "xl", Approx: 500_000,
		Projects: 100, Users: 1_000, Labels: 40,
		Issues: 250_000, Comments: 150_000, Notes: 500, Flats: 98_000,
		NoteChars: 4_000, IssueBodyChars: 160,
	},
}

Tiers are the corpus sizes the benchmarks run at. The names are what /debug/seed and the workspace ids use.

xl exists to be run partial-only: a full-sync client is expected to be unhappy at half a million rows, and measuring how unhappy is the point of having the tier rather than a reason to leave it out.

Functions

func IssueKey

func IssueKey(i int) string

IssueKey is the row key of the i-th seeded issue. Exported because the benchserver's write endpoint addresses seeded rows by key: a caller building the key itself would, if the format ever drifted, silently create new rows where it meant to touch existing ones and still look like it worked.

func Options

func Options() []server.Option

Options returns the entity registrations for the bench corpus.

func SearchSizeKey added in v0.4.0

func SearchSizeKey(kind, i int) string

SearchSizeKey returns the i-th key of a kind: a UUIDv7 in 26-character Crockford base32, the shape newId makes in the client. The timestamp increases with i and the random bits come from a PRNG seeded by kind and i, so the same arguments always give the same key.

func WorkspaceID

func WorkspaceID(tier string) string

WorkspaceID is the workspace a tier's corpus is seeded into. One workspace per tier, stable across runs, so a seeded database can be cached and reused.

Types

type Counts

type Counts struct {
	Projects int `json:"projects"`
	Users    int `json:"users"`
	Labels   int `json:"labels"`
	Issues   int `json:"issues"`
	Comments int `json:"comments"`
	Notes    int `json:"notes"`
	Flats    int `json:"flats"`
	Total    int `json:"total"`
}

Counts is what a seed run wrote, per entity.

func Seed

func Seed(
	ctx context.Context,
	srv *server.Server,
	workspaceID string,
	tier Tier,
	seed uint64,
	progress Progress,
) (Counts, error)

Seed generates a tier's corpus and writes it into workspaceID as trusted server-side writes, bypassing the client wire entirely — half a million rows pushed through Push would measure the seeding, not the benchmark.

Deterministic in (tier, seed): the same pair always produces the same rows in the same order, which is what lets a seeded database be cached and reused (see GeneratorVersion).

The workspace is assumed empty. Seeding a workspace twice writes the corpus twice under the same keys — harmless for row content, since every key is overwritten with the identical value, but it doubles the workspace's history and therefore what a bootstrap has to walk past. The harness seeds once into a cached database instead.

func SeedSearchSize added in v0.4.0

func SeedSearchSize(ctx context.Context, srv *server.Server, workspaceID string) (Counts, error)

SeedSearchSize writes the text-heavy search corpus into workspaceID as trusted writes and builds the workspace's indexes: SearchSizeProjects projects, SearchSizeUsers users and SearchSizeIssues issues, each issue with a title and a body of Zipf-distributed words. The result is the same on every call. The workspace is assumed empty.

type Progress

type Progress func(entity string, done, total int)

Progress reports seeding progress. Seeding the largest tier takes minutes, so a caller that would otherwise look hung gets something to print.

type Tier

type Tier struct {
	// Name as the harness and the workspace id spell it ("s", "m", "l", "xl").
	Name string `json:"name"`
	// Rough total, for reporting. The exact total is what Counts sums to.
	Approx int `json:"approx"`

	Projects int `json:"projects"`
	Users    int `json:"users"`
	Labels   int `json:"labels"`
	Issues   int `json:"issues"`
	Comments int `json:"comments"`
	Notes    int `json:"notes"`
	Flats    int `json:"flats"`

	// Characters in each note's collaborative-text body. Byte weight without
	// row weight: raising this moves bootstrap bytes without moving row counts,
	// which is what separates the two costs in a result table.
	NoteChars int `json:"noteChars"`
	// Characters in an issue body. The bulk entity's payload-weight dial.
	IssueBodyChars int `json:"issueBodyChars"`
}

Tier is one corpus size. The counts are chosen so issues and comments dominate — a real tracker's shape — with the remainder in the flat control entity, and so that the total lands near the tier's advertised row count. The json tags are load-bearing: /debug/tiers serves this struct to the benchmark harness, and TypeScript reads the field names.

func (Tier) Total

func (t Tier) Total() int

Total is the number of rows a seeded tier holds.

Jump to

Keyboard shortcuts

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