binary_to_types is slower than it should be, simply because it spends a large amount of its time performing a huge number of single-byte read syscalls.
When reading from a source against which short reads are not efficient, such as a File, you will want to apply your own buffering because serde_json will not buffer the input. See std::io::BufReader.
This PR adds the necessary std::io::BufReader to the places I saw it as necessary. To see the difference simply run binary_to_types with strace with an without this PR.
This PR also fixes up a trivial warning about unnecessary parenthesis, which I thought would be uncontroversial to include in the same PR, just to keep noise low. Let me know if I should open it as a separate PR instead (it's already as a separate commit in this PR fwiw).
binary_to_types
is slower than it should be, simply because it spends a large amount of its time performing a huge number of single-byteread
syscalls.The documentation for
serde_json::from_reader
states:This PR adds the necessary
std::io::BufReader
to the places I saw it as necessary. To see the difference simply runbinary_to_types
withstrace
with an without this PR.This PR also fixes up a trivial warning about unnecessary parenthesis, which I thought would be uncontroversial to include in the same PR, just to keep noise low. Let me know if I should open it as a separate PR instead (it's already as a separate commit in this PR fwiw).