Sign in

When it comes to correctness guarantees, there are few communities in Computer Science (software) more obsessed with them than the database and distributed system communities. They better be serious about correctness because everyone’s bank account balances depend on it.

You have heard about terms like Paxos, consensus, fault tolerance, but…


FoundationDB is a very impressive database. Its paper won the best industry paper award in SIGMOD’21. In this post, I will explain, in detail, how FDB works and discuss a few very interesting design choices they made. It’s a dense paper packed with neat ideas. Many details (sometimes even proof…


Paxos, is the famous synonym for consistency in the context of distributed system. Unfortunately, consistency alone, is such an overloaded term, it’s often practically meaningless. In this post, I will explain the difference between Paxos-consistency vs. quorum-consistency.

I assume you know what Paxos is and what problem it solves. If…


Memoization is an old technique. It’s basically caching outputs for giving inputs (usually in a map). But a map lookup itself is not free. How can we memoize map lookups?

I learned from my coworker this nifty trick recently. Let’s say we have a map (e.g. std::unordered_map<K,V>, for which the…


Lamport proposed Paxos Commit algorithm as an alternative to 2PC for achieving Transaction Commit. It’s a very natural application of the Paxos algorithm (if you have read this post, where I pointed out Paxos is effectively itself a read-modify-write transaction protocol.)

There’s one subtle difference between 2PC and Paxos Commit…


C++ language include an operator called typeid ( https://en.cppreference.com/w/cpp/language/typeid).

Queries information of a type.
Used where the dynamic type of a polymorphic object must be known and for static type identification.

It gives you information about the type of an object, as long as it’s available.

int a = 0…

When going through the folly code base, sometimes, you see definitions like

class FOLLY_EXPORT OptionalEmptyException : public std::runtime_error { ...

FOLLY_EXPORT is defined as

#define FOLLY_EXPORT __attribute__((__visibility__("default")))

It sets the visibility attribute of symbol OptionalEmptyException to "default". What does it do exactly, and how it works?

Static Library

We will start with…


The basic concept of a read-write lock is simple. It allows multiple readers to access the resource simultaneously, but at most one thread can have exclusive ownership of the lock (a.k.a write lock). It’s supposed to be an optimization, comparing to simple mutex (e.g. std::mutex). As in theory, multiple readers…


I started working on it on and off, since July 2019. Burnt a few chips and stripped hundreds feet of wires.

The following is a video of the computer running a program on the right. It ran a loop that keeps adding 10, until it overflowed and halted the clock.

Because I burnt the 74LS138 demux, I decided to run the computer without it. So each instruction takes full 8 clock cycles unnecessarily. So you would see a lot of the time when the computer is not doing anything.

I highly recommend Ben Eater’s YouTube channel.

Tags: breadboard

Originally published at https://blog.the-pans.com on June 6, 2020.


This is the first post of a series of posts I plan to make about TLA+.

What is a computer

First, let’s take a look at a very philosophical question — “what is a computer?”. I am writing this post on my computer, which has 32 GB of RAM and 8 2.4 GHz cores…

Lu Pan

Software Engineer at Facebook working on cache infrastructure

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store