Learning C++ Memory Model from a Distributed System's Perspective

If C++ standard were reworded using distributed system terms, it might be more readable. Your single machine is actually a distributed system in disguiseMultiple cachelines inside your multi-core machine make a distributed system. Cacheline coherence is 100% a distributed system problem. C++ tries to provide a high level abstraction for…

Fiber-compatible Future

folly's Future API is Fiber-compatible. Calling get() on a folly::Future object will only suspend the calling fiber-task. It won't block the system thread, letting it process other tasks. – https://github.com/facebook/folly/blob/master/folly/fibers/README.mdBut how does it actually work? E.g. what happens when…

DNS – the first distributed database

DNS was created in 1983. Before then, Stanford was storing the host name to IP address map on HOSTS.TXT, which obviously doesn't scale. DNS is the address book of the internet, which performs a simple function of translating domains to IP addresses. One way of looking at it is…

There's Nothing 100% in Computer Science

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…

When would someone use std::enable_shared_from_this

std::enable_shared_from_this allows a class to have a valid shared_ptr of this. Simply adding a member function that returns shared_ptr<T>(this) is susceptible to double-free. But when would you use such a feature? It's a relevant question because, next time when you…

How FoundationDB works and why it works

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 vs. Quorum-based Consistency

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…

Build `folly::coro` with GCC

You have heard about Coroutine in C++, and you want to use it. There're two coroutine implementations that are considered most mature - cppcoro and folly::coro. They are written by the same guy - Lewis Baker. He's brilliant, and you shoud watch his cppcon talk on structured concurrency if…