Context
resume_push_chunk and the mainline push_streamed_wire_chunks both do Bytes::copy_from_slice(&acc[..take]) - a 4 MiB memcpy per ack round-trip. For an 88 GB resume that's roughly 22,000 redundant copies.
Ask
Swap the accumulators in both paths to bytes::BytesMut with split_to(take).freeze() instead of Bytes::copy_from_slice, to avoid the redundant memcpy per chunk.
Care needed
This is NOT a drop-in swap. The partial-ack retry path re-pushes unacked bytes, so the split_to needs bookkeeping to avoid losing the unacked tail when a partial ack requires re-sending part of what was already split off.
resume_push_chunk and push_streamed_wire_chunks should change together (or neither) to avoid the two implementations diverging in behavior.
Reference
PR #279 (fix(core): stream the resumable-upload resume instead of buffering the whole file) - deferred hardening item from its multi-agent review.
Context
resume_push_chunkand the mainlinepush_streamed_wire_chunksboth doBytes::copy_from_slice(&acc[..take])- a 4 MiB memcpy per ack round-trip. For an 88 GB resume that's roughly 22,000 redundant copies.Ask
Swap the accumulators in both paths to
bytes::BytesMutwithsplit_to(take).freeze()instead ofBytes::copy_from_slice, to avoid the redundant memcpy per chunk.Care needed
This is NOT a drop-in swap. The partial-ack retry path re-pushes unacked bytes, so the
split_toneeds bookkeeping to avoid losing the unacked tail when a partial ack requires re-sending part of what was already split off.resume_push_chunkandpush_streamed_wire_chunksshould change together (or neither) to avoid the two implementations diverging in behavior.Reference
PR #279 (fix(core): stream the resumable-upload resume instead of buffering the whole file) - deferred hardening item from its multi-agent review.