Skip to content

Commit

Permalink
swarm/storage: ldbstore garbage collection counters
Browse files Browse the repository at this point in the history
  • Loading branch information
nonsense committed May 8, 2018
1 parent dd1f6c1 commit a626673
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 a626673

Please sign in to comment.