Artifact 65e8e147b1007811e9c7dfa76b28ffb7a0b2149d011bd46216a3ec6507463eb2:
- File
internal/content/export_test.go
— part of check-in
[b53551c192]
at
2026-10-28 22:44:17
on branch perf/memo-tree-encoding
— perf(content): read trees lazily again, kept in the compact encoding
A full read of every tree with the graph made a cold classification on fossil-scm.org's clone three to four times slower, which an origin that starts cold often cannot afford. Walks read a tree when they first need it, as before, and the memo keeps what they read as a treeIndex (interned ids, delta-varint sets, full manifests as differences), replaced on each publish so views read it without the lock. memoTreeBytes now bounds that encoding, which holds the whole history of fossil-scm.org in about 11 MiB; past it the index starts again. HZ-6.2-10 stays partial: trees are still read on first use, not with the graph. (user: [email protected], size: 1651) [annotate] [blame] [check-ins using]
package content import ( "context" "maps" "slices" "github.com/danmestas/go-libfossil/db" ) // LoadAbsencesWithin is LoadAbsencesContext under injected budgets, and // reports what classification read. The tests that use it are an external // package: their fixtures need the manifest writer, which imports this one. func LoadAbsencesWithin( ctx context.Context, q db.Querier, refs ReferenceBudget, treePerCheckin int64, ) (*Absences, ReferenceWork, error) { treeMax := treePerCheckin << 10 if treeMax > defaultReferenceLimits.treeMax { treeMax = defaultReferenceLimits.treeMax } a, err := loadAbsences(ctx, q, referenceLimits{ refs: refs, treePerCheckin: treePerCheckin, treeMax: treeMax, }) if a == nil { return nil, ReferenceWork{}, err } return a, a.work, err } // LoadAbsencesWork is LoadAbsencesContext, reporting what classification // read under the default budgets. func LoadAbsencesWork(ctx context.Context, q db.Querier) (*Absences, ReferenceWork, error) { limits := defaultReferenceLimits return LoadAbsencesWithin(ctx, q, limits.refs, limits.treePerCheckin) } // TreesRead names the trees v's horizon walks read from the store, and // counts the reads. func (v *MemoView) TreesRead() (names []string, reads int) { return slices.Collect(maps.Keys(v.trees)), v.treeReads } // TreeBytes is what m charges for the trees it keeps. func (m *Memo) TreeBytes() int64 { m.mu.Lock() defer m.mu.Unlock() if m.trees == nil { return 0 } return m.trees.bytes } // LimitTrees sets the most m keeps of its walks' trees. func (m *Memo) LimitTrees(bytes int64) { m.mu.Lock() defer m.mu.Unlock() m.treeLimit = bytes }