trailofbits / binary_type_inference

GNU General Public License v3.0
15 stars 2 forks source link

Speed up file loads #68

Closed jaybosamiya closed 3 weeks ago

jaybosamiya commented 1 month ago

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.

The documentation for serde_json::from_reader states:

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).

CLAassistant commented 1 month ago

CLA assistant check
All committers have signed the CLA.

2over12 commented 3 weeks ago

LGTM thanks!