Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Efficient implementation of vectored writes for BufWriter #3163

Merged
merged 8 commits into from Jun 29, 2021

Commits on Jun 28, 2021

  1. io: implement vectored output for BufWriter

    Implement AsyncWrite::poll_write_vectored for BufWriter, making use
    of the buffer to coalesce data from the passed slices. Make exceptions
    for cases when writing directly to the underlying object is more
    efficient, which differ depending on whether the underlying writer
    itself supports vectored output.
    
    Change the implementation of AsyncWrite::is_write_vectored to return
    true.
    mzabaluev committed Jun 28, 2021
    Copy the full SHA
    db53287 View commit details
    Browse the repository at this point in the history
  2. io: vectored output for BufReader and BufStream

    Forward poll_write_vectored/is_write_vectored to the underlying object
    for BufReader.
    
    Do the same in BufStream, which has the effect of is_write_vectored
    returning true because BufWriter's implementation now does.
    mzabaluev committed Jun 28, 2021
    Copy the full SHA
    f805b69 View commit details
    Browse the repository at this point in the history
  3. io: simplify poll_write_vectored for BufWriter

    Simplify branching and do what poll_write does: do not buffer
    slices partially, optimizing for the most likely case where slices
    are much smaller than the buffer, while retaining special treatment
    for oversized slices.
    mzabaluev committed Jun 28, 2021
    Copy the full SHA
    ab30c42 View commit details
    Browse the repository at this point in the history
  4. Copy the full SHA
    32f8a8d View commit details
    Browse the repository at this point in the history
  5. io: guard against integer overflow in BufWriter

    In the implementation of AsyncWrite::poll_write_vectored
    for BufWriter, the total length of the data can technically overflow
    usize even with safely obtained buffer slices, since slices may
    overlap.
    mzabaluev committed Jun 28, 2021
    Copy the full SHA
    30a6591 View commit details
    Browse the repository at this point in the history

Commits on Jun 29, 2021

  1. Rewrite non-vectored branch in poll_write_vectored

    Improve readability by updating the IOSlice vector slice as
    constituent slices are gone over by the iteration, rather than
    using an iterator.
    mzabaluev committed Jun 29, 2021
    Copy the full SHA
    f0d443d View commit details
    Browse the repository at this point in the history
  2. More readability fixes in poll_write_vectored

    Partially incorporated code suggested by @Darksonn.
    mzabaluev committed Jun 29, 2021
    Copy the full SHA
    2dff0ad View commit details
    Browse the repository at this point in the history
  3. BufWriter: assert the buffer is empty when bypassing

    Co-authored-by: Alice Ryhl <alice@ryhl.io>
    mzabaluev and Darksonn committed Jun 29, 2021
    Copy the full SHA
    598560b View commit details
    Browse the repository at this point in the history