Commit 28eb389
committed
perf: ensure full write buffer for *File.ReadFrom
In `*File.ReadFrom`, ensure that the buffer is filled to capacity (`maxPacket`
length) before performing the write.
Prior to this change, the amount of data read into the buffer was dictated by
the `io.Reader`'s `Read` implementation, and write performance would suffer
when the Read would return less than maxPacket bytes of data. An example
source would be a `net/http` response `Body` from a TLS server, which
seems to cap each read to 16384 bytes -- half the default max packet size of
32768 bytes.1 parent 19bfb49 commit 28eb389
1 file changed
+6
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1842 | 1842 | | |
1843 | 1843 | | |
1844 | 1844 | | |
1845 | | - | |
| 1845 | + | |
| 1846 | + | |
1846 | 1847 | | |
1847 | 1848 | | |
1848 | 1849 | | |
| |||
1868 | 1869 | | |
1869 | 1870 | | |
1870 | 1871 | | |
1871 | | - | |
| 1872 | + | |
1872 | 1873 | | |
1873 | 1874 | | |
1874 | 1875 | | |
| |||
2022 | 2023 | | |
2023 | 2024 | | |
2024 | 2025 | | |
2025 | | - | |
| 2026 | + | |
| 2027 | + | |
2026 | 2028 | | |
2027 | 2029 | | |
2028 | 2030 | | |
| |||
2039 | 2041 | | |
2040 | 2042 | | |
2041 | 2043 | | |
2042 | | - | |
| 2044 | + | |
2043 | 2045 | | |
2044 | 2046 | | |
2045 | 2047 | | |
| |||
0 commit comments