Skip to content

Commit

Permalink
d_lru: no prealloc, increase limit (#12822)
Browse files Browse the repository at this point in the history
- no prealloc to reduce unit-tests RAM use
  • Loading branch information
AskAlexSharov authored Nov 22, 2024
1 parent 336260e commit f4e5d1e
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions erigon-lib/state/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type domainGetFromFileCacheItem struct {
}

var (
domainGetFromFileCacheLimit = uint32(dbg.EnvInt("D_LRU", 1_000))
domainGetFromFileCacheLimit = uint32(dbg.EnvInt("D_LRU", 10_000))
domainGetFromFileCacheTrace = dbg.EnvBool("D_LRU_TRACE", false)
domainGetFromFileCacheEnabled = dbg.EnvBool("D_LRU_ENABLED", true)
)
Expand Down Expand Up @@ -59,19 +59,8 @@ func newDomainVisible(name kv.Domain, files []visibleFile) *domainVisible {
files: files,
caches: &sync.Pool{New: NewDomainGetFromFileCacheAny},
}
// Not on hot-path: better pre-alloc here
d.preAlloc()
return d
}
func (v *domainVisible) preAlloc() {
var preAlloc [10]any
for i := 0; i < len(preAlloc); i++ {
preAlloc[i] = v.caches.Get()
}
for i := 0; i < len(preAlloc); i++ {
v.caches.Put(preAlloc[i])
}
}

func (v *domainVisible) newGetFromFileCache() *DomainGetFromFileCache {
if !domainGetFromFileCacheEnabled {
Expand Down

0 comments on commit f4e5d1e

Please sign in to comment.