Skip to content

Commit

Permalink
Move/rename aristo_desc.accLruSize => aristo_constants.ACC_LRU_SIZE
Browse files Browse the repository at this point in the history
  • Loading branch information
mjfh committed Aug 13, 2024
1 parent 13d61ba commit 59f236f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 4 additions & 0 deletions nimbus/db/aristo/aristo_constants.nim
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ const
## functions with fixed assignments of the type of a state root (e.g. for
## a receipt or a transaction root.)

ACC_LRU_SIZE* = 1024 * 1024
## LRU cache size for accounts that have storage, see `.accLeaves` and
## `.stoLeaves` fields of the main descriptor.

static:
# must stay away from `VertexID(1)` and `VertexID(2)`
doAssert 2 < LEAST_FREE_VID
Expand Down
4 changes: 2 additions & 2 deletions nimbus/db/aristo/aristo_delta.nim
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,12 @@ proc deltaPersistent*(
for accPath, vtx in db.balancer.accLeaves:
let accKey = accPath.to(AccountKey)
if not db.accLeaves.lruUpdate(accKey, vtx):
discard db.accLeaves.lruAppend(accKey, vtx, accLruSize)
discard db.accLeaves.lruAppend(accKey, vtx, ACC_LRU_SIZE)

for mixPath, vtx in db.balancer.stoLeaves:
let mixKey = mixPath.to(AccountKey)
if not db.stoLeaves.lruUpdate(mixKey, vtx):
discard db.stoLeaves.lruAppend(mixKey, vtx, accLruSize)
discard db.stoLeaves.lruAppend(mixKey, vtx, ACC_LRU_SIZE)

# Done with balancer, all saved to backend
db.balancer = LayerRef(nil)
Expand Down
4 changes: 0 additions & 4 deletions nimbus/db/aristo/aristo_desc.nim
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ export
tables, aristo_constants, desc_error, desc_identifiers, desc_nibbles,
desc_structural, keyed_queue

const
accLruSize* = 1024 * 1024
# LRU cache size for accounts that have storage

type
AristoTxRef* = ref object
## Transaction descriptor
Expand Down
4 changes: 2 additions & 2 deletions nimbus/db/aristo/aristo_fetch.nim
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ proc retrieveAccountPayload(
return err(FetchPathNotFound)
return err(error)

ok db.accLeaves.lruAppend(accKey, leafVtx, accLruSize).lData
ok db.accLeaves.lruAppend(accKey, leafVtx, ACC_LRU_SIZE).lData

proc retrieveMerkleHash(
db: AristoDbRef;
Expand Down Expand Up @@ -188,7 +188,7 @@ proc retrieveStoragePayload(
leafVtx = db.retrieveLeaf(? db.fetchStorageID(accPath), stoPath.data).valueOr:
return err(error)

ok db.stoLeaves.lruAppend(mixKey, leafVtx, accLruSize).lData.stoData
ok db.stoLeaves.lruAppend(mixKey, leafVtx, ACC_LRU_SIZE).lData.stoData

proc hasStoragePayload(
db: AristoDbRef;
Expand Down

0 comments on commit 59f236f

Please sign in to comment.