Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

d_lru: no prealloc, increase limit #12822

Merged
merged 3 commits into from
Nov 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading