-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: LRUcache for block requests #630
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
import { IBlock } from '../../types/responses'; | ||
|
||
export const initLRUCache = (): LRU<string, IBlock> => { | ||
const config = { max: 2 }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does max == 2
mean here? The two most recent blocks can be cached in memory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, exactly. The max length of the cache wont exceed 2. This is actually kinda up in the air, but from a brief discussion with Zeke we figured 1-2 would be more sufficient for the needs of polling blocks/head
.
Before merging this too, I am going to confirm that when running stress tests, and benchmarks that this doesnt cause any residual issues for sidecar. |
After running benchmarks against 9.1.4 and this PR, there were no regressions: v9.1.4
This branch
No regressions I can tell, ran two more sets of benchmarks and they all are similar. @dvdplm any last thoughts before I merge this? |
closes: #612
LRUcache implemented for a
/blocks/head
&/blocks/{blockId}
.The main benefit of having this LRUCache is making sure that when users are polling
/blocks/head
for the most recent block it doesnt make repeat requests for the same blockHash.