Tim Mastny
banner
timmastny.bsky.social
Tim Mastny
@timmastny.bsky.social
Software engineer bringing digital finance to Africa. Writes about low-level programming, data science, and algorithms at https://timmastny.com
The cache line is the smallest unit of data unique to each CPU cache, commonly 64 or 128 bytes. If a CPU wants to modify a variable on a cache line, it must coordinate with all other CPUs to invalidate their copy, even if they some of the variables on that line are not shared.
February 18, 2025 at 6:28 PM
Which program is faster? 1/
February 18, 2025 at 6:28 PM
Pointer chasing is slow, but the number is limited to the height of the tree. Scanning is fast, but quickly adds up. Our model combines these costs: for any number of total keys, we can calculate the optimal number of keys per node 'b' that minimizes total search time.
February 11, 2025 at 6:54 PM
Search in B+ trees is a balance of two operations: scanning within nodes (1ns each) and jumping between nodes (100ns each). The size of each node determines how many of each operation we do - and that's why finding the optimal node size is crucial for performance.
February 11, 2025 at 6:54 PM
Latest demo: collaborative text editing synchronized with a conflict-free data structure.

The data structure ensures that insertions, edits, and deletions are properly merged during synchronization. Even if the changes were made offline. 1/
January 27, 2025 at 7:19 PM
When analyzing branch prediction algorithms, the "better" hashing approach (gshare) is theoretically worse than the simple one (concatenation).

What's going on?
January 15, 2025 at 8:19 PM
Branch instructions like if statements create another challenge: workers don't know what to work on next. Instead of waiting, they guess what to do next - even if they might have to throw away their work. This is called branch prediction. 4/5
January 8, 2025 at 10:49 PM
But what happens when a worker needs a part that's still being worked on? The whole line has to pause - this is called a data hazard. 3/5
January 8, 2025 at 10:49 PM
With pipelining, each worker begins the next task as soon as they finish. Just like an assembly line, throughput increases dramatically. 2/5
January 8, 2025 at 10:49 PM
Let's explain CPU pipelining using an assembly line metaphor. In a basic CPU, only one worker is active. The others must wait until the entire instruction completes before starting the next one. 1/5
January 8, 2025 at 10:49 PM