-
-
Notifications
You must be signed in to change notification settings - Fork 438
fix: prune serialized cache by block input keys #9007
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
Changes from all commits
4cd3c91
b1659d9
2b01a87
ef57b07
223a244
2f34f24
5f200c7
427cb03
9af31bd
5a2da67
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,7 @@ | |
| * This is a thin wrapper around WeakMap | ||
| */ | ||
| export class SerializedCache { | ||
| map: WeakMap<object, Uint8Array> = new WeakMap(); | ||
| private map: WeakMap<object, Uint8Array> = new WeakMap(); | ||
|
|
||
| get(obj: object): Uint8Array | undefined { | ||
| return this.map.get(obj); | ||
|
|
@@ -15,11 +15,13 @@ export class SerializedCache { | |
| } | ||
|
|
||
| /** | ||
| * Replace the internal WeakMap to force GC of all cached entries. | ||
| * Must only be called after all DB writes that may read from this cache have completed, | ||
| * Delete cached serialized entries for the provided object references. | ||
| * Must only be called after all DB writes that read from this cache for these objects have completed, | ||
| * otherwise cached serialized bytes will be unavailable and data will be re-serialized unnecessarily. | ||
| */ | ||
| clear(): void { | ||
| this.map = new WeakMap(); | ||
| delete(objs: object[]): void { | ||
| for (const obj of objs) { | ||
| this.map.delete(obj); | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also check if
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this isn't possible, there is no reliable way to get the size of there is also no place in the code where we could do the previous I would rather keep track of how many items the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see 427cb03, I coupled the serialized cache pruning more closely to block input so there is less of a chance to have dangling entries |
||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.