Skip to content
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

The result of deep_size_of_interned is incorrect #51

Closed
gmryuuko opened this issue Jun 19, 2024 · 3 comments · Fixed by #52
Closed

The result of deep_size_of_interned is incorrect #51

gmryuuko opened this issue Jun 19, 2024 · 3 comments · Fixed by #52

Comments

@gmryuuko
Copy link
Contributor

gmryuuko commented Jun 19, 2024

The crate deepsize implements DeepSizeOf trait for all references. And it only calculates the size of the reference itself, not the size of the pointed-to object.

https://github.com/Aeledfyr/deepsize/blob/5deebe687695610e6038dc70753defbe7634d549/src/lib.rs#L421-L444

Therefore, we must manually dereference before calling deep_size_of.

INTERN_CONTAINERS.with(|m: &mut HashSet<&'static T>| -> usize { m.deep_size_of() })

@gmryuuko
Copy link
Contributor Author

#52

@droundy
Copy link
Owner

droundy commented Jun 19, 2024 via email

@gmryuuko
Copy link
Contributor Author

I won't have time to look at your pull request soon, but wanted to mention that you'll need to make sure to use the tricky "Context" to ensure that the same data doesn't get counted twice, if a data structure has two interned pointers to the same value. David Roundy

On Wed, Jun 19, 2024, 6:10 AM Gmry @.> wrote: #52 <#52> — Reply to this email directly, view it on GitHub <#51 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABBSKN6U6C5UYOE3224WPDZIF7LLAVCNFSM6AAAAABJR3NRG6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNZYGY4DKNZZG4 . You are receiving this because you are subscribed to this thread.Message ID: @.>

The Context will be correctly passed to the objects in the HashSet. And added more test cases for Context.

https://github.com/droundy/internment/pull/52/files#diff-4d290cbd1a1b1f16004466de2efd9706f162a7c32da7ea4cdc1da8f590111da6R580

droundy added a commit that referenced this issue Jun 22, 2024
fix `deep_size_of_interned` always returns a fixed value (close #51)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants