Skip to content

Increasing read chunk size could improve performance for large responses #135

@florimondmanca

Description

@florimondmanca

Coming from discussion on Gitter with @dalf

Currently we are reading response data in chunks of 4kB…

READ_NUM_BYTES = 4096

READ_NUM_BYTES = 4096

Benchmarking using @dalf's pyhttp-benchmark tool led us to see that increasing this number to 64kB could lead 2-3x execution time improvement for large responses (typically > 256kB).

My rationale would be that reading N bytes in one go via a syscall is faster than reading n = N/k bytes k times — mostly because the kernel is way faster than Python.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions