mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
Merge f1f7ba92e2 into bd1f7ebda2
This commit is contained in:
commit
baac864497
2 changed files with 13 additions and 5 deletions
|
|
@ -248,7 +248,7 @@ func decodeData(addr Address, data []byte) (*chunk, error) {
|
|||
}
|
||||
|
||||
func (s *LDBStore) collectGarbage(ratio float32) {
|
||||
log.Trace("collectGarbage", "ratio", ratio)
|
||||
log.Trace("collectGarbage", "ratio", ratio, "entrycnt", s.entryCnt)
|
||||
|
||||
metrics.GetOrRegisterCounter("ldbstore.collectgarbage", nil).Inc(1)
|
||||
|
||||
|
|
@ -258,7 +258,7 @@ func (s *LDBStore) collectGarbage(ratio float32) {
|
|||
garbage := []*gcItem{}
|
||||
gcnt := 0
|
||||
|
||||
for ok := it.Seek([]byte{keyIndex}); ok && (gcnt < maxGCitems) && (uint64(gcnt) < s.entryCnt); ok = it.Next() {
|
||||
for ok := it.Seek([]byte{keyIndex}); ok && (uint64(gcnt) < s.entryCnt); ok = it.Next() {
|
||||
itkey := it.Key()
|
||||
|
||||
if (itkey == nil) || (itkey[0] != keyIndex) {
|
||||
|
|
@ -290,7 +290,11 @@ func (s *LDBStore) collectGarbage(ratio float32) {
|
|||
|
||||
sort.Slice(garbage[:gcnt], func(i, j int) bool { return garbage[i].value < garbage[j].value })
|
||||
|
||||
if gcnt > maxGCitems {
|
||||
gcnt = maxGCitems
|
||||
}
|
||||
cutoff := int(float32(gcnt) * ratio)
|
||||
|
||||
metrics.GetOrRegisterCounter("ldbstore.collectgarbage.delete", nil).Inc(int64(cutoff))
|
||||
|
||||
for i := 0; i < cutoff; i++ {
|
||||
|
|
@ -727,6 +731,7 @@ func (s *LDBStore) tryAccessIdx(ikey []byte, index *dpaDBIndex) bool {
|
|||
case s.batchesC <- struct{}{}:
|
||||
default:
|
||||
}
|
||||
log.Trace("tryaccessidx", "addr", fmt.Sprintf("%x", ikey[1:]), "indexdata", index, "data", idata)
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ package storage
|
|||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
|
@ -385,8 +386,10 @@ func TestLDBStoreAddRemove(t *testing.T) {
|
|||
|
||||
// TestLDBStoreRemoveThenCollectGarbage tests that we can delete chunks and that we can trigger garbage collection
|
||||
func TestLDBStoreRemoveThenCollectGarbage(t *testing.T) {
|
||||
capacity := 11
|
||||
surplus := 4
|
||||
//capacity := 11
|
||||
//surplus := 4
|
||||
capacity := 10000
|
||||
surplus := 10000
|
||||
|
||||
ldb, cleanup := newLDBStore(t)
|
||||
ldb.setCapacity(uint64(capacity))
|
||||
|
|
@ -423,7 +426,7 @@ func TestLDBStoreRemoveThenCollectGarbage(t *testing.T) {
|
|||
cleanup()
|
||||
|
||||
ldb, cleanup = newLDBStore(t)
|
||||
capacity = 10
|
||||
//capacity = 10000
|
||||
ldb.setCapacity(uint64(capacity))
|
||||
defer cleanup()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue