Introduction Link to heading Imagine you opened Activity Monitor to check how much memory your application consumes. But wait, which number should you actually look at? Suppose there’s “Memory” showing 800 MB, and “Real Memory” showing 1 GB. What’s the difference? Note Activity Monitor doesn’t display those two readings by default. To show them, you need to right-click on a table header and select them. This exact scenario happened to me more times than I’d like to admit. As s...| bazhenov.me
Introduction Link to heading In this article, I discuss the challenges associated with testing algorithm performance, focusing primarily on microbenchmarks rather than overall application performance, although some principles apply to both. I provide a brief overview of efforts to address these challenges and highlight some limitations we’re encountering. Subsequently, I introduce an alternative method of performance testing called paired benchmarking, which effectively tackles some of thes...| Posts on bazhenov.me
Introduction Link to heading Good weather is specific weather. Conclusion: there is no such thing as good weather. Pilot’s proverb TLDR: The very same machine code, placed at different addresses, can exhibit drastically different performance. As software developers, we often assume that the performance of a specific piece of code is determined solely by the code itself and the hardware it runs on. This assumption gives us a sense of control when optimizing code for better performance.| www.bazhenov.me
Introduction Link to heading Varint is a widely recognized technique used for compressing integer streams. Essentially, it suggests that it can be more efficient to encode a number using a variable-length representation instead of a fixed-size binary representation. By removing leading zeros from the binary number, the overall representation size can be reduced. This technique works particularly well for encoding smaller numbers. In this article, I provide a brief introduction and rationale f...| www.bazhenov.me
Introducton Link to heading Binary search is a very fast algorithm. Due to its exponential nature, it can process gigabytes of sorted data quickly. However, two problems make it somewhat challenging for modern CPUs: predictability of instruction flow; predictability of memory access. At each step, binary search splits the dataset into two parts and jumps to one of those parts based on a midpoint value. It’s difficult for the CPU to predict which parts of the presumably large array will be a...| www.bazhenov.me
Introduction Link to heading Suppose we need to write a function that computes the next set of numbers in a range and stores them in a slice, as shown below: let pl = RangePl::new(1..12); let mut buffer = [0u64; 4]; pl.next_batch(0, &mut buffer); // returns 4, buffer[..] = [1, 2, 3, 4] pl.next_batch(0, &mut buffer); // returns 4, buffer[..] = [5, 6, 7, 8] pl.next_batch(10, &mut buffer); // returns 2, buffer[0.| www.bazhenov.me
In recent years, criticism of the classic object-oriented analysis and design ideas has grown increasingly louder. One example of such criticism is Clean Code, Horrible Performance by Case Muratori. Here’s a quote that explains the author’s idea: It simply cannot be the case that we’re willing to give up a decade or more of hardware performance just to make programmers’ lives a little bit easier. Our job is to write programs that run well on the hardware that we are given.| www.bazhenov.me