fix: prune serialized cache by block input keys#9007
fix: prune serialized cache by block input keys#9007
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the cache management strategy for serialized objects within the beacon node. By transitioning from a global cache clear to a more precise, block-input-specific deletion mechanism, it prevents unintended data eviction and improves the reliability of cached serialized data, particularly for complex block types like those involving blobs or columns. This change ensures that cached objects remain available as long as they are potentially needed by other processes, optimizing resource utilization and data consistency. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a more granular cache pruning mechanism for SerializedCache. Instead of clearing the entire cache, it now selectively deletes entries related to a processed block. This is achieved by adding a getSerializedCacheKeys() method to IBlockInput and its implementations, and a delete() method to SerializedCache. The changes are well-implemented and improve both performance and correctness by avoiding premature cache eviction. I've suggested one minor improvement for code consistency.
Performance Report✔️ no performance regression detected Full benchmark results
|
twoeths
left a comment
There was a problem hiding this comment.
looks good to me
I'd also track the size of serializedCache to make sure we don't have an issue of dangling entries
| delete(objs: object[]): void { | ||
| for (const obj of objs) { | ||
| this.map.delete(obj); | ||
| } |
There was a problem hiding this comment.
also check if this.map.size === 0 then create a new WeakMap
There was a problem hiding this comment.
this isn't possible, there is no reliable way to get the size of WeakMap, we can only track entries manually but this would be inaccurate since we wouldn't deduct dangling entries that are dropped automatically
there is also no place in the code where we could do the previous clear() and create a new WeakMap but I don't really think this is necessary, if we want more manual control over the stored items we should just use a normal Map
I would rather keep track of how many items the BlockInput's added to SerializedCache and add more explicit clean up there if entries are pruned automatically to make sure we explicitly clean up dangling BlockInput's
There was a problem hiding this comment.
see 427cb03, I coupled the serialized cache pruning more closely to block input so there is less of a chance to have dangling entries
|
@codex review |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
getSerializedCacheKeys()to block input variantsSerializedCacheandSeenBlockInputSerializedCache.clear()usage to avoid premature cache eviction