swarm/storage: log if we evict an outgoing request

This commit is contained in:
Anton Evangelatov 2018-04-16 15:29:38 +03:00
parent 25cd805bea
commit 158b776bfc
2 changed files with 5 additions and 5 deletions

View file

@ -246,7 +246,6 @@ func decodeOldData(data []byte, chunk *Chunk) {
} }
func (s *LDBStore) collectGarbage(ratio float32) { func (s *LDBStore) collectGarbage(ratio float32) {
log.Info("collect garbage", "ratio", ratio)
it := s.db.NewIterator() it := s.db.NewIterator()
defer it.Release() defer it.Release()
@ -286,7 +285,6 @@ func (s *LDBStore) collectGarbage(ratio float32) {
sort.Slice(garbage[:gcnt], func(i, j int) bool { return garbage[i].value < garbage[j].value }) sort.Slice(garbage[:gcnt], func(i, j int) bool { return garbage[i].value < garbage[j].value })
cutoff := int(float32(gcnt) * ratio) cutoff := int(float32(gcnt) * ratio)
log.Info("cutoff", "cutoff", cutoff, "gcnt", gcnt)
for i := 0; i < cutoff; i++ { for i := 0; i < cutoff; i++ {
s.delete(garbage[i].idx, garbage[i].idxKey, garbage[i].po) s.delete(garbage[i].idx, garbage[i].idxKey, garbage[i].po)
} }
@ -563,7 +561,6 @@ func (s *LDBStore) writeBatches() {
} }
close(c) close(c)
for e > s.capacity { for e > s.capacity {
log.Info("collecting garbage", "entryCnt", e, "capacity", s.capacity)
s.collectGarbage(gcArrayFreeRatio) s.collectGarbage(gcArrayFreeRatio)
e = s.entryCnt e = s.entryCnt
} }
@ -695,7 +692,6 @@ func (s *LDBStore) setCapacity(c uint64) {
ratio = 1 ratio = 1
} }
for s.entryCnt > c { for s.entryCnt > c {
log.Info("collecting garbage (set.capacity)", "entryCnt", s.entryCnt, "capacity", c)
s.collectGarbage(ratio) s.collectGarbage(ratio)
} }
} }

View file

@ -21,6 +21,7 @@ package storage
import ( import (
"sync" "sync"
"github.com/ethereum/go-ethereum/log"
lru "github.com/hashicorp/golang-lru" lru "github.com/hashicorp/golang-lru"
) )
@ -53,7 +54,10 @@ func NewMemStore(params *StoreParams, _ *LDBStore) (m *MemStore) {
panic(err) panic(err)
} }
r, err := lru.New(int(params.ChunkRequestsCacheCapacity)) requestEvicted := func(key interface{}, value interface{}) {
log.Error("evict called on outgoing request")
}
r, err := lru.NewWithEvict(int(params.ChunkRequestsCacheCapacity), requestEvicted)
if err != nil { if err != nil {
panic(err) panic(err)
} }