Commit 892232da authored by Kirill Smelkov's avatar Kirill Smelkov

X δbtail: tests: Use Clone in verify_rebuild

	$ time go test -failfast -short -run 'ΔBTail/rebuild' >x

before:

	real    1m44,975s
	user    2m18,809s
	sys     0m12,384s

after:

	real    1m15,669s
	user    1m31,340s
	sys     0m10,171s
parent f0453574
......@@ -449,6 +449,46 @@ func NewΔBtail(at0 zodb.Tid, db *zodb.DB) *ΔBtail {
}
}
// xverifyΔBTail_rebuild needs ΔBTree.clone because otherwise it is too slow to run that test.
func (orig *ΔBtail) clone() *ΔBtail {
klon := NewΔBtail(orig.Tail(), orig.db)
// δZtail
for _, δZ := range orig.δZtail.Data() {
klon.δZtail.Append(δZ.Rev, δZ.Changev)
}
// trackIdx
for oid, t := range orig.trackIdx {
klon.trackIdx[oid] = &nodeTrack{parent: t.parent, nchild: t.nchild}
}
// trackNew
for oid, t := range orig.trackNew {
klon.trackNew[oid] = &nodeTrack{parent: t.parent, nchild: t.nchild}
}
// byRoot
for root, origΔTtail := range orig.byRoot {
klonΔTtail := &ΔTtail{}
klonΔTtail.vδT = append(klonΔTtail.vδT, origΔTtail.vδT...)
for k, v := range origΔTtail.KVAtTail {
klonΔTtail.KVAtTail[k] = v
}
for k, rev := range origΔTtail.lastRevOf {
klonΔTtail.lastRevOf[k] = rev
}
klon.byRoot[root] = klonΔTtail
}
// holeIdxByRoot
for root, origHoleIdx := range orig.holeIdxByRoot {
klonHoleIdx := treeSetKey{SetKey{}}
klonHoleIdx.Update(origHoleIdx.SetKey)
klon.holeIdxByRoot[root] = klonHoleIdx
}
return klon
}
// newΔTtail creates new empty ΔTtail object.
func newΔTtail() *ΔTtail {
return &ΔTtail{
......@@ -520,8 +560,8 @@ func (δBtail *ΔBtail) Track(key Key, keyPresent bool, path []Node) error { //
func (δBtail *ΔBtail) holeIdxFor(root zodb.Oid) treeSetKey {
holeIdx, ok := δBtail.holeIdxByRoot[root]
if !ok {
holeIdx = treeSetKey{SetKey{}}
δBtail.holeIdxByRoot[root] = holeIdx
holeIdx = treeSetKey{SetKey{}}
δBtail.holeIdxByRoot[root] = holeIdx
}
return holeIdx
}
......
......@@ -912,11 +912,10 @@ func xverifyΔBTail_rebuild(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, t0, t1
t.Run(fmt.Sprintf(" →%s T%s;R", t2.tree, keys2), func(t *testing.T) {
// XXX implement Clone and go the clone way if test starts running too slow
//δbtail_ := δbtail.Clone()
δbtail = NewΔBtail(t0.at, db)
step1()
δbtail_ := δbtail
//δbtail = NewΔBtail(t0.at, db)
//step1()
//δbtail_ := δbtail
δbtail_ := δbtail.clone()
// tracked keys1 becomes tracked keys1_2 after Update(t1->t2)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment