fix: EXC: Fix memory_bytes#5813
Closed
berestovskyy wants to merge 2 commits intomasterfrom
Closed
Conversation
5005a47 to
3155802
Compare
The PR fixes the `memory_bytes` getters around the codebase. The implementation takes care of determinism (by using deterministic `len`) and performance (by not calculating the deep `Vec` or `BTreeSet` sizes). Due to the above, the size calculated by the `memory_bytes` is still an estimation, not an exact value. The PR also adds a few tests to future-proof the size calculations in query cache.
3155802 to
e446659
Compare
mraszyk
reviewed
Jul 3, 2025
Contributor
mraszyk
left a comment
There was a problem hiding this comment.
The comment about shallow vs deep estimate is more general: what's the strategy to decide between shallow vs deep estimates?
The point regarding using { .. } applies throughout.
| impl MemoryDiskBytes for Time { | ||
| /// Returns the total number of bytes that this object occupies | ||
| /// in stack and heap memory. | ||
| fn memory_bytes(&self) -> usize { |
Contributor
There was a problem hiding this comment.
Ideally we'd make this implementation "frozen" so that people can't override it, but I guess that is not possible.
Contributor
Author
There was a problem hiding this comment.
Not as a trait, but as a public function:
deterministic_total_bytes(&obj);
vs now with trait:
obj.deterministic_total_bytes();
Contributor
Author
|
Closing in favor of #6445 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The PR fixes the
memory_bytesgetters around the codebase.The implementation takes care of determinism (by using deterministic
len) and performance (by not calculating the deepVecorBTreeSetsizes).Due to the above, the size calculated by the
memory_bytesis still an estimation, not an exact value.The PR also adds a few tests to future-proof the size calculations in query cache.