You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "kumarUjjawal (via GitHub)" <gi...@apache.org> on 2026/08/07 09:39:31 UTC

Re: [PR] GC & Deduplicate String View on Spill [datafusion]

kumarUjjawal commented on code in PR #23565:
URL: https://github.com/apache/datafusion/pull/23565#discussion_r3734842301


##########
datafusion/physical-plan/src/spill/mod.rs:
##########
@@ -420,6 +420,20 @@ pub(crate) fn gc_view_arrays(batch: &RecordBatch) -> Result<RecordBatch> {
     }
 }
 
+/// Garbage collect and deduplicate a string view before writing it out to disk
+///
+/// This is to avoid inflating disk usage and also to ensure that deduplication reduces memory pressure when reading back.
+fn gc_dedup_view<T: ByteViewType>(
+    array: &GenericByteViewArray<T>,
+) -> GenericByteViewArray<T> {
+    let mut builder = GenericByteViewBuilder::<T>::with_capacity(array.len())

Review Comment:
   Every qualifying Utf8View and BinaryView now allocates a hash table sized for all rows and hashes every non-inline value. This is valuable for repeated values, but  unique strings or large binary values get no disk reduction over gc() while paying extra CPU and peak memory during spilling.



##########
datafusion/physical-plan/src/spill/mod.rs:
##########
@@ -1345,7 +1359,7 @@ mod tests {
         let size_without_gc: usize = array_without_gc
             .data_buffers()
             .iter()
-            .map(|buffer| buffer.capacity())
+            .map(|buffer| buffer.len())

Review Comment:
   Keep coverage for both length and capacity.



-- 
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: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org