Skip to content

Commit

Permalink
d_lru: to store decompressed values (#12951)
Browse files Browse the repository at this point in the history
- decompressing CodeDomain values: taking ~7% of execution speed
  • Loading branch information
AskAlexSharov authored Dec 2, 2024
1 parent 73b12da commit 33732fb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions erigon-lib/state/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type domainGetFromFileCacheItem struct {
lvl uint8
exists bool
offset uint64
v []byte
}

var (
Expand Down
14 changes: 7 additions & 7 deletions erigon-lib/state/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down

0 comments on commit 33732fb

Please sign in to comment.