Skip to content

Speed up http client#633

Merged
arnetheduck merged 1 commit intomasterfrom
bulkcopy
Apr 7, 2026
Merged

Speed up http client#633
arnetheduck merged 1 commit intomasterfrom
bulkcopy

Conversation

@arnetheduck
Copy link
Copy Markdown
Member

The http client currently uses an inefficient byte-by-byte copy in its BoundedStreamReader - the real solution here is to get rid of the copy completely but until then, we can use bulk-copy the data at least.

Ditto read, readN and similar helpers - this ~doubles throughput for bulk reading.

Pre:

| Small/small    |    0.070s |   1000 | 14226.009 |    0.031 MB |    0.016 MB |    0.434 MB/s |    0.231 MB/s |
| Medium/small   |    1.834s |   1000 |  545.267 | 1000.000 MB |    0.021 MB |  545.267 MB/s |    0.011 MB/s |
| Small/Medium   |    2.238s |   1000 |  446.735 |    0.031 MB | 1000.000 MB |    0.014 MB/s |  446.735 MB/s |
| Medium/Medium  |    2.583s |   1000 |  387.196 | 1000.000 MB | 1000.000 MB |  387.196 MB/s |  387.196 MB/s |

Post:

| Small/small    |    0.066s |   1000 | 15038.890 |    0.031 MB |    0.016 MB |    0.459 MB/s |    0.244 MB/s |
| Medium/small   |    0.954s |   1000 | 1048.475 | 1000.000 MB |    0.021 MB | 1048.475 MB/s |    0.022 MB/s |
| Small/Medium   |    1.264s |   1000 |  791.318 |    0.031 MB | 1000.000 MB |    0.024 MB/s |  791.318 MB/s |
| Medium/Medium  |    1.615s |   1000 |  619.083 | 1000.000 MB | 1000.000 MB |  619.083 MB/s |  619.083 MB/s |

@arnetheduck arnetheduck marked this pull request as ready for review April 7, 2026 12:57
Base automatically changed from bulkread to master April 7, 2026 13:50
The http client currently uses an inefficient byte-by-byte copy in its
`BoundedStreamReader` - the real solution here is to get rid of the
copy completely but until then, we can use bulk-copy the data at least.

Ditto `read`, `readN` and similar helpers - this ~doubles throughput
for bulk reading.

Pre:
```
| Small/small    |    0.070s |   1000 | 14226.009 |    0.031 MB |    0.016 MB |    0.434 MB/s |    0.231 MB/s |
| Medium/small   |    1.834s |   1000 |  545.267 | 1000.000 MB |    0.021 MB |  545.267 MB/s |    0.011 MB/s |
| Small/Medium   |    2.238s |   1000 |  446.735 |    0.031 MB | 1000.000 MB |    0.014 MB/s |  446.735 MB/s |
| Medium/Medium  |    2.583s |   1000 |  387.196 | 1000.000 MB | 1000.000 MB |  387.196 MB/s |  387.196 MB/s |
```

Post:

```
| Small/small    |    0.066s |   1000 | 15038.890 |    0.031 MB |    0.016 MB |    0.459 MB/s |    0.244 MB/s |
| Medium/small   |    0.954s |   1000 | 1048.475 | 1000.000 MB |    0.021 MB | 1048.475 MB/s |    0.022 MB/s |
| Small/Medium   |    1.264s |   1000 |  791.318 |    0.031 MB | 1000.000 MB |    0.024 MB/s |  791.318 MB/s |
| Medium/Medium  |    1.615s |   1000 |  619.083 | 1000.000 MB | 1000.000 MB |  619.083 MB/s |  619.083 MB/s |
```
@arnetheduck arnetheduck merged commit 6080fef into master Apr 7, 2026
26 checks passed
@arnetheduck arnetheduck deleted the bulkcopy branch April 7, 2026 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant