From 158b776bfc9675f2f0b4d8fb09ee4001d480e4c7 Mon Sep 17 00:00:00 2001 From: Anton Evangelatov Date: Mon, 16 Apr 2018 15:29:38 +0300 Subject: [PATCH] swarm/storage: log if we evict an outgoing request --- swarm/storage/ldbstore.go | 4 ---- swarm/storage/memstore_lrucache.go | 6 +++++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/swarm/storage/ldbstore.go b/swarm/storage/ldbstore.go index 8c18e88a12..42fa731aaf 100644 --- a/swarm/storage/ldbstore.go +++ b/swarm/storage/ldbstore.go @@ -246,7 +246,6 @@ func decodeOldData(data []byte, chunk *Chunk) { } func (s *LDBStore) collectGarbage(ratio float32) { - log.Info("collect garbage", "ratio", ratio) it := s.db.NewIterator() 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 }) cutoff := int(float32(gcnt) * ratio) - log.Info("cutoff", "cutoff", cutoff, "gcnt", gcnt) for i := 0; i < cutoff; i++ { s.delete(garbage[i].idx, garbage[i].idxKey, garbage[i].po) } @@ -563,7 +561,6 @@ func (s *LDBStore) writeBatches() { } close(c) for e > s.capacity { - log.Info("collecting garbage", "entryCnt", e, "capacity", s.capacity) s.collectGarbage(gcArrayFreeRatio) e = s.entryCnt } @@ -695,7 +692,6 @@ func (s *LDBStore) setCapacity(c uint64) { ratio = 1 } for s.entryCnt > c { - log.Info("collecting garbage (set.capacity)", "entryCnt", s.entryCnt, "capacity", c) s.collectGarbage(ratio) } } diff --git a/swarm/storage/memstore_lrucache.go b/swarm/storage/memstore_lrucache.go index a66dcd0c22..70bd709728 100644 --- a/swarm/storage/memstore_lrucache.go +++ b/swarm/storage/memstore_lrucache.go @@ -21,6 +21,7 @@ package storage import ( "sync" + "github.com/ethereum/go-ethereum/log" lru "github.com/hashicorp/golang-lru" ) @@ -53,7 +54,10 @@ func NewMemStore(params *StoreParams, _ *LDBStore) (m *MemStore) { 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 { panic(err) }