Plurrrr

Thu 02 Mar 2023

Rust's BufRead, And When To Use It

Rust is a low-level language, and its standard library is careful to give the programmer lots of control over how things will behave and avoid implicit behavior, especially when that behavior impacts performance. But at the same time, it doesn't want to make the programmer's life harder than it needs to be. As a result, Rust's language features and standard library often give you access to really low-level concepts with no assumptions baked in, but then also give you abstractions you can optionally layer on top.

One example of this is the Read and BufRead traits. Read is a low-level and unopinionated abstraction for ingesting data from things like files, network sockets, and process input, while BufRead represents a specific kind of layer you can choose to put on top of Read to make it slightly higher-level.

Source: Rust's BufRead, And When To Use It, an article by Brandon Smith.

Beware microbenchmarks bearing gifts

Benchmarks are only a tool for debugging efficiency: Production is ultimately what matters. Benchmarks analyze the performance of code under the specific circumstances created and maintained by the benchmark. They cannot perfectly predict the performance of code in the real world. In this episode, we discuss some of the pitfalls of microbenchmarks and mitigation strategies.

Source: Performance Tip of the Week #39: Beware microbenchmarks bearing gifts, an article by Chris Kennelly and Alkis Evlogimenos.