Documentation
¶
Overview ¶
Package storebench is Prototype #1 (see docs/architecture/data-layer.md, "Provenance"): the write-path benchmark that gated the v2 store decision. It implements a minimal-but-faithful version of the proposed OWNED columnar write path — dictionary-interned structure-of-arrays columns in a recycled rowId arena, sorted indexes over (sortKey, uid), and exact facet counters — so we can measure whether sustained ingest + churn holds up at 100k–1M objects before committing to building the real engine.
This is benchmark scaffolding, not production code: it models one kind's columns (a pod-like row) and two sort orders (CPU, memory). The question it answers is narrow and load-bearing: does an incrementally-maintained columnar Append keep per-event cost O(log N) across its index fan-out and sustain a churn storm, versus the naive "rebuild + full sort per query" baseline.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ColumnarStore ¶
type ColumnarStore struct {
// contains filtered or unexported fields
}
ColumnarStore is the proposed owned write path, minimized to one kind.
func NewColumnarStore ¶
func NewColumnarStore(expected int) *ColumnarStore
NewColumnarStore builds an empty store sized for an expected row count.
func (*ColumnarStore) Delete ¶
func (s *ColumnarStore) Delete(uid string)
Delete removes an object, maintaining every index + facet incrementally.
func (*ColumnarStore) NamespaceCount ¶
func (s *ColumnarStore) NamespaceCount(ns string) int
NamespaceCount returns the exact live count for a namespace — an O(1) facet read, the win over re-counting N rows per query.
func (*ColumnarStore) TopByCPU ¶
func (s *ColumnarStore) TopByCPU(limit int) []Object
TopByCPU returns up to limit rows with the highest CPU (descending) — the keyset page read: a bounded range scan over the sorted index, O(log N + page), never a full sort.
func (*ColumnarStore) Upsert ¶
func (s *ColumnarStore) Upsert(o Object)
Upsert inserts or updates an object, maintaining every index + facet incrementally — the per-event work the v2 store relies on (O(log N) per index, never O(N)).
type Object ¶
type Object struct {
UID string
Namespace string
Name string
CPUMilli int64
MemBytes int64
Status string
}
Object is a minimal pod-like row for the benchmark.
type TrigramIndex ¶
type TrigramIndex struct {
// contains filtered or unexported fields
}
TrigramIndex is a minimal substring-search prototype: a trigram inverted index (trigram -> set of rowIds) with verify-after-intersect to drop false positives. It answers the v2 risk: can filter-as-you-type stay sub-frame at 1M rows, and what does maintaining the index cost per write?
Postings are map-of-sets (O(1) add/remove) rather than compressed bitmaps; that over-spends memory but is faithful for measuring QUERY latency and per-event maintenance cost, which is what gates the design. (A real engine would use roaring bitmaps for the postings to make the index fit in memory at 1M.)
func NewTrigramIndex ¶
func NewTrigramIndex(expected int) *TrigramIndex
NewTrigramIndex builds an empty index sized for an expected row count.
func (*TrigramIndex) Add ¶
func (t *TrigramIndex) Add(rowID uint32, name string)
Add indexes a new row's name.
func (*TrigramIndex) Remove ¶
func (t *TrigramIndex) Remove(rowID uint32)
Remove drops a row from the index.
func (*TrigramIndex) Search ¶
func (t *TrigramIndex) Search(sub string, limit int) []uint32
Search returns up to limit rowIds whose name contains sub (case-insensitive). It intersects the query's trigram posting sets (smallest first) and verifies the actual substring on each candidate to eliminate trigram false positives.
func (*TrigramIndex) Update ¶
func (t *TrigramIndex) Update(rowID uint32, name string)
Update re-indexes a row whose name changed (remove old trigrams, add new).