Reserve the memory into_packed_data() allocates - #23894
Conversation
4641835 to
2376f3d
Compare
2376f3d to
32b04d2
Compare
32b04d2 to
eca1764
Compare
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 12 included reviews per hour; 10 remain after this review. 📝 WalkthroughSummary by CodeRabbit
Walkthrough
ChangesTable chunk packing
Estimated code review effort: 3 (Moderate) | ~25 minutes Merge Risk: ⚪ Minimal · up to The change adds explicit memory reservation for table packing and updates the represented C++ and Python callers. No actionable merge-blocking risk remains after normal checks and review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
When a
table_chunkis not already packed,into_packed_data()callscudf::pack()straight intobr->device_mr(). The allocation is roughly the size of the table and nothing reserved it, so the memory system under-counts and backpressure cannot see it coming.It now takes a
MemoryReservationinstead of aBufferResource, andinto_packed_data_cost()reports what it will allocate. That is zero when the chunk is already packed, since the packed data is then moved out rather than serialized, so the sole caller reserves the right amount on every path rather than over-reserving on the spilled one.Both non-packed constructors already compute
cudf::packed_size()intodata_alloc_size_, so the cost needs no extra work at call time.Breaking change
into_packed_data()takes aMemoryReservationrather than aBufferResource, in C++ and in Python. TheBufferResourceoverload is gone rather than kept alongside, since every other allocating method ontable_chunkalready takes a reservation and leaving it would leave a blocking path that is easier to reach than the correct one.Callers pair it with
into_packed_data_cost():Note
The
cudf::chunked_pack()TODO on the same line is still open. A bounce buffer would bound the allocation instead of needing room for a whole second copy.