cache only contains vertices at height 5000, 10000, etc.

This commit is contained in:
Dan Laine 2020-06-19 12:18:20 -04:00
parent a3d3ef4787
commit 8b75abdee0
1 changed files with 11 additions and 1 deletions

View File

@ -17,7 +17,14 @@ import (
)
const (
cacheSize = 100000
// We cache processed vertices where height = c * stripeDistance for c = {1,2,3...}
// This forms a "stripe" of cached DAG vertices at height stripeDistance, 2*stripeDistance, etc.
// This helps to limit the number of repeated DAG traversals performed
//
// With stripeDistance == 2500, average DAG width == 25 and processedCache size == 100,000
// the graph can have depth up to 10,000,000 and hold every stripe in cache (100,000 / 25 == x / 2,500)
stripeDistance = 2500
cacheSize = 100000
)
// BootstrapConfig ...
@ -175,6 +182,9 @@ func (b *bootstrapper) process(vtxs ...avalanche.Vertex) error {
toProcess.Push(parent)
}
}
if vtx.Height()%stripeDistance == 0 {
b.processedCache.Put(vtx.ID(), nil)
}
b.processedCache.Put(vtx.ID(), nil)
}
}