kosiew commented on code in PR #23349:
URL: https://github.com/apache/datafusion/pull/23349#discussion_r3535226558
##########
datafusion/common/src/heap_size.rs:
##########
@@ -281,11 +281,23 @@ impl<K: DFHeapSize, V: DFHeapSize> DFHeapSize for
HashMap<K, V> {
}
}
+fn count_allocation_once(ptr: usize, ctx: &mut DFHeapSizeCtx) -> bool {
+ ctx.seen.insert(ptr)
+}
+
+fn arc_ptr<T>(arc: &Arc<T>) -> usize {
+ Arc::as_ptr(arc) as usize
+}
+
+fn arc_unsized_ptr<T: ?Sized>(arc: &Arc<T>) -> usize {
Review Comment:
Nice extraction. Would it be worth adding a short comment here explaining
why the fat pointer metadata is intentionally discarded and only the allocation
(data) address is used for deduplication? That was already the existing
behavior, but now that it lives in one helper, documenting the invariant here
would make future changes to `Arc<str>` or `Arc<dyn DFHeapSize>` a little
easier to reason about.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]