Artifact 22d8f54b16e4f2c90d1b93e1fb7ba1daa59acabce163b11e168db37600ea40ee:
- File
internal/content/export_test.go
— part of check-in
[7ba1eb6915]
at
2026-10-28 23:43:43
on branch main
— perf(content): bound and test the memo's compact trees
Count the decoded file set a tree index keeps as the next difference's base toward memoTreeBytes, check a decoded id's gap without wrapping in uint64, and say what cloning the index on publish costs (about 0.5ms for fossil-scm.org's whole history, BenchmarkTreeIndexClone).
TestMemoWideTreesMatchFresh classifies every cone over wide trees that rename, delete and add files, in all three manifest forms, with chains of differences 15 long and with a limit that starts the index again, before and after the store gains check-ins; a branch heads the chains trunk trees continue, so a trunk horizon decodes trees whose chain starts outside its held set. (user: [email protected], size: 1940) [annotate] [blame] [check-ins using] [more...]
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 } // TreeChainDepth is the most set differences any tree m keeps lies from // one kept whole. func (m *Memo) TreeChainDepth() int { m.mu.Lock() defer m.mu.Unlock() depth := 0 if m.trees != nil { for _, p := range m.trees.pieces { depth = max(depth, p.depth) } } return depth }