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

Fix quadratic behavior of repeated vectored writes #121938

Merged
merged 1 commit into from
Mar 8, 2024

Commits on Mar 3, 2024

  1. Fix quadratic behavior of repeated vectored writes

    Some implementations of `Write::write_vectored` in the standard
    library (`BufWriter`, `LineWriter`, `Stdout`, `Stderr`) check all
    buffers to calculate the total length. This is O(n) over the number of
    buffers.
    
    It's common that only a limited number of buffers is written at a
    time (e.g. 1024 for `writev(2)`). `write_vectored_all` will then call
    `write_vectored` repeatedly, leading to a runtime of O(n²) over the
    number of buffers.
    
    The fix is to only calculate as much as needed if it's needed.
    blyxxyz committed Mar 3, 2024
    Configuration menu
    Copy the full SHA
    8212fc5 View commit details
    Browse the repository at this point in the history