Skip to content

Zero-copy wire-chunk handoff (BytesMut) in the resumable push paths #283

Description

@pmaxhogan

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    • Status
      Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions