You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Some Array.slice() is used unnecessarily just for api convenience, this not only affects performance (as a new array is copied) but also cause gc to run more frequently. Some examples:
then we loop canonicalBlocks. In this case we can just do a for loop over i and toIdx
stateContextCache
prune(headStateRootHex: RootHex): void{constkeys=Array.from(this.cache.keys());if(keys.length>this.maxStates){// object keys are stored in insertion order, delete keys starting from the frontfor(constkeyofkeys.slice(0,keys.length-this.maxStates)){
in this case we can just do a regular for loop and break if it goes beyond the limit.
Describe the solution you'd like
Audit the use of Array.slice() in lodestar, only use it if it's really needed
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
Some
Array.slice()
is used unnecessarily just for api convenience, this not only affects performance (as a new array is copied) but also causegc
to run more frequently. Some examples:then we loop
canonicalBlocks
. In this case we can just do a for loop overi
andtoIdx
in this case we can just do a regular
for
loop and break if it goes beyond the limit.Describe the solution you'd like
Audit the use of
Array.slice()
in lodestar, only use it if it's really neededThe text was updated successfully, but these errors were encountered: