quick/minimal mitigation of beacon_node memory usage resulting from 2*Table.defaultInitialSize pointless BeaconState objects in block pool state cache (#1002)

This commit is contained in:
tersec 2020-05-10 16:31:55 +00:00 committed by GitHub
parent 592d6f65c3
commit c498103b2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -233,8 +233,8 @@ proc init*(T: type BlockPool, db: BeaconChainDB,
pending: initTable[Eth2Digest, SignedBeaconBlock](),
missing: initTable[Eth2Digest, MissingBlock](),
cachedStates: [
newTable[tuple[a: Eth2Digest, b: Slot], StateData](),
newTable[tuple[a: Eth2Digest, b: Slot], StateData]()
newTable[tuple[a: Eth2Digest, b: Slot], StateData](initialSize = 2),
newTable[tuple[a: Eth2Digest, b: Slot], StateData](initialSize = 2)
],
blocks: blocks,
tail: tailRef,
@ -383,7 +383,7 @@ proc putState(pool: BlockPool, state: HashedBeaconState, blck: BlockRef) =
# resulting lookback window is thus >= SLOTS_PER_EPOCH in size, while
# bounded from above by 2*SLOTS_PER_EPOCH.
pool.cachedStates[epochParity] =
newTable[tuple[a: Eth2Digest, b: Slot], StateData]()
newTable[tuple[a: Eth2Digest, b: Slot], StateData](initialSize = 2)
else:
# Need to be able to efficiently access states for both attestation
# aggregation and to process block proposals going back to the last