eclipse-vertx / eclipse-vertx/vert.x
Make sendFile fallback chunk size configurable
- Dominant language
- Java
- Stars
- 14.7k
- Forks
- 2.1k
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 27
Description
### Describe the feature
`HttpServerResponse.sendFile(...)` can use different internal paths depending on the protocol and connection capabilities.
When the native file-region/sendfile path is available, the file can be transferred efficiently by the OS. However, when this path is not available, for example with TLS, HTTP/2, HTTP/3, traffic shaping, or unsupported transports, Vert.x falls back to streaming the file through userspace.
Today these fallback paths use a fixed 8 KiB chunk/read size, for example in `ChunkedNioFile` and the `AsyncFile`-based fallback path. This value is conservative, but it can be suboptimal for larger files.
In a local benchmark serving a 1 MiB file, increasing the fallback chunk size to 32 KiB, 64 KiB, or 128 KiB significantly reduced overhead compared to the current 8 KiB default.
It would be useful to expose an option for configuring the fallback send-file chunk size, while keeping the current default behavior unchanged. The option should be ignored when the native file-region/sendfile path is used.
### Contribution
(https://github.com/eclipse-vertx/vert.x/pull/6159)
Contributor guide
Assessment
This issue has not been assessed yet.