A new package that monitors the localstore and storage radius from batchstore to control puller syncing changes.
func init() {
initiliazeDepthFromStatestore()
waitNodeWarmup()
if storage_depth == 0,
storage_depth = kademlia.connectionDepth()
go manage()
}
func manage() {
while {
if reserve.Size() / reserve.Capacity() < 0.5 {
storage_depth--
kademlia.setDepth(storage_depth)
}
sleep(5 minutes)
}
}
// reported by batchstore
func SetStorageRadius(storage_radius) {
if oldStorageRadius >= storage_depth && storage_radius < storage_depth {
storage_depth = storage_radius
kademlia.setDepth(storage_depth)
}
if storage_radius > storage_depth {
storage_depth = storage_radius
kademlia.setDepth(storage_depth)
}
oldStorageRadius = storage_radius
}
Notes from 23/6
improve manage loop by monitoring pullsync
depth may be decreased if after historical syncing for a particular bin, the reserve size is still below 50% capacity
NOTES:
kademlia has to be aware of storage depth to tweak neighborhood radius to maintain full connectivity
func manage() {
secondsInHour := 60 * 60
adaptationPeriod := false
reserveNotHalfFull := func() bool {
return reserve.Size() / reserve.Capacity() < 0.5
}
for {
sleep(5 minutes)
if reserveNotHalfFull() && !adaptationPeriod {
adaptationPeriod = true
timeAtStart := time.Now()
}
if !reserveNotHalfFull() {
adaptationPeriod = false
}
// given the current pull rate (chunks per second), and the time left (1 hour minus the seconds since we started), is the current rate enough to fill half of the reserve on top of what's already there
if adaptationPeriod && pullsync.Rate() * (secondsInHour - seconds.Since(timeAtStart)) < (reserve.Capacity() / 2 - reserve.Size()) {
storage_depth--
kademlia.setDepth(storage_depth)
}
}
reference https://hackmd.io/yzrmd3GhTDCyDnEkwzrjeg?view
Depth Package (needs a new name)
A new package that monitors the localstore and storage radius from batchstore to control puller syncing changes.
Notes from 23/6
NOTES:
func manage() {
}