From 33732fb5035a365dbc4e3a230b07554b8becb937 Mon Sep 17 00:00:00 2001 From: Alex Sharov Date: Mon, 2 Dec 2024 20:48:56 +0700 Subject: [PATCH] d_lru: to store decompressed values (#12951) - decompressing CodeDomain values: taking ~7% of execution speed --- erigon-lib/state/cache.go | 1 + erigon-lib/state/domain.go | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/erigon-lib/state/cache.go b/erigon-lib/state/cache.go index e3efef88227..3a718284ae7 100644 --- a/erigon-lib/state/cache.go +++ b/erigon-lib/state/cache.go @@ -27,6 +27,7 @@ type domainGetFromFileCacheItem struct { lvl uint8 exists bool offset uint64 + v []byte } var ( diff --git a/erigon-lib/state/domain.go b/erigon-lib/state/domain.go index 4eea0477597..51b45eb1256 100644 --- a/erigon-lib/state/domain.go +++ b/erigon-lib/state/domain.go @@ -1541,11 +1541,11 @@ func (dt *DomainRoTx) getFromFiles(filekey []byte, maxTxNum uint64) (v []byte, f if !cv.exists { return nil, true, dt.files[cv.lvl].startTxNum, dt.files[cv.lvl].endTxNum, nil } - g := dt.statelessGetter(int(cv.lvl)) - g.Reset(cv.offset) - g.Skip() - v, _ = g.Next(nil) // can be compressed - return v, true, dt.files[cv.lvl].startTxNum, dt.files[cv.lvl].endTxNum, nil + //g := dt.statelessGetter(int(cv.lvl)) + //g.Reset(cv.offset) + //g.Skip() + //v, _ = g.Next(nil) // can be compressed + return cv.v, true, dt.files[cv.lvl].startTxNum, dt.files[cv.lvl].endTxNum, nil } } @@ -1589,7 +1589,7 @@ func (dt *DomainRoTx) getFromFiles(filekey []byte, maxTxNum uint64) (v []byte, f } if dt.getFromFileCache != nil { - dt.getFromFileCache.Add(hi, domainGetFromFileCacheItem{lvl: uint8(i), offset: offset, exists: true}) + dt.getFromFileCache.Add(hi, domainGetFromFileCacheItem{lvl: uint8(i), offset: offset, exists: true, v: v}) } return v, true, dt.files[i].startTxNum, dt.files[i].endTxNum, nil } @@ -1598,7 +1598,7 @@ func (dt *DomainRoTx) getFromFiles(filekey []byte, maxTxNum uint64) (v []byte, f } if dt.getFromFileCache != nil { - dt.getFromFileCache.Add(hi, domainGetFromFileCacheItem{lvl: 0, offset: 0, exists: false}) + dt.getFromFileCache.Add(hi, domainGetFromFileCacheItem{lvl: 0, offset: 0, exists: false, v: nil}) } return nil, false, 0, 0, nil }