Skip to content

Commit

Permalink
Merge pull request ethereum#515 from ethersphere/ldbstore_garbage_met…
Browse files Browse the repository at this point in the history
…rics

swarm/storage: ldbstore garbage collection counters
  • Loading branch information
nonsense authored May 8, 2018
2 parents dd1f6c1 + a626673 commit bd1b79f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions swarm/storage/ldbstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@ func decodeOldData(data []byte, chunk *Chunk) {
}

func (s *LDBStore) collectGarbage(ratio float32) {
metrics.GetOrRegisterCounter("ldbstore.collectgarbage", nil).Inc(1)

it := s.db.NewIterator()
defer it.Release()

Expand Down Expand Up @@ -287,6 +289,8 @@ 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)
metrics.GetOrRegisterCounter("ldbstore.collectgarbage.delete", nil).Inc(int64(cutoff))

for i := 0; i < cutoff; i++ {
s.delete(garbage[i].idx, garbage[i].idxKey, garbage[i].po)
}
Expand Down

0 comments on commit bd1b79f

Please sign in to comment.