halve memory usage from state caches
This commit is contained in:
parent
f53425873c
commit
fc8502c54e
|
@ -356,11 +356,14 @@ func putStateCache(
|
|||
# with the concomitant memory allocator and GC load. Instead, use a
|
||||
# more memory-intensive (but more conceptually straightforward, and
|
||||
# faster) strategy to just store, for the most recent slots.
|
||||
if state.data.slot mod 2 != 0:
|
||||
return
|
||||
|
||||
let stateCacheIndex = dag.getStateCacheIndex(blck.root, state.data.slot)
|
||||
if stateCacheIndex == -1:
|
||||
# Could use a deque or similar, but want simpler structure, and the data
|
||||
# items are small and few.
|
||||
const MAX_CACHE_SIZE = 32
|
||||
const MAX_CACHE_SIZE = 16
|
||||
|
||||
let cacheLen = dag.cachedStates.len
|
||||
doAssert cacheLen <= MAX_CACHE_SIZE
|
||||
|
|
|
@ -174,12 +174,12 @@ proc slash_validator*(state: var BeaconState, slashed_index: ValidatorIndex,
|
|||
validator.effective_balance div MIN_SLASHING_PENALTY_QUOTIENT)
|
||||
|
||||
# The rest doesn't make sense without there being any proposer index, so skip
|
||||
# Apply proposer and whistleblower rewards
|
||||
let proposer_index = get_beacon_proposer_index(state, cache)
|
||||
if proposer_index.isNone:
|
||||
debug "No beacon proposer index and probably no active validators"
|
||||
return
|
||||
|
||||
# Apply proposer and whistleblower rewards
|
||||
let
|
||||
# Spec has whistleblower_index as optional param, but it's never used.
|
||||
whistleblower_index = proposer_index.get
|
||||
|
|
Loading…
Reference in New Issue