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

Optimize BufWriter #79930

Merged
merged 7 commits into from
May 6, 2021
Merged

Commits on Apr 13, 2021

  1. BufWriter: apply #[inline] / #[inline(never)] optimizations

    Ensure that `write` and `write_all` can be inlined and that their
    commonly executed fast paths can be as short as possible.
    
    `write_vectored` would likely benefit from the same optimization, but I
    omitted it because its implementation is more complex, and I don't have
    a benchmark on hand to guide its optimization.
    tgnottingham committed Apr 13, 2021
    Configuration menu
    Copy the full SHA
    1f32d40 View commit details
    Browse the repository at this point in the history
  2. BufWriter: avoid using expensive Vec methods

    We use a Vec as our internal, constant-sized buffer, but the overhead of
    using methods like `extend_from_slice` can be enormous, likely because
    they don't get inlined, because `Vec` has to repeat bounds checks that
    we've already done, and because it makes considerations for things like
    reallocating, even though they should never happen.
    tgnottingham committed Apr 13, 2021
    Configuration menu
    Copy the full SHA
    b43e8e2 View commit details
    Browse the repository at this point in the history
  3. BufWriter: optimize for write sizes less than buffer size

    Optimize for the common case where the input write size is less than the
    buffer size. This slightly increases the cost for pathological write
    patterns that commonly fill the buffer exactly, but if a client is doing
    that frequently, they're already paying the cost of frequent flushing,
    etc., so the cost is of this optimization to them is relatively small.
    tgnottingham committed Apr 13, 2021
    Configuration menu
    Copy the full SHA
    5fd9372 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    72aecbf View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    85bc88d View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    0f29dc4 View commit details
    Browse the repository at this point in the history

Commits on Apr 14, 2021

  1. Configuration menu
    Copy the full SHA
    01e7018 View commit details
    Browse the repository at this point in the history