Linear scalable read-write lock

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…

Global Data Locality – Why and How

Why In folly, Facebook's open source c++ library, you often see code like the following: #define FOLLY_SETTING_DEFINE(_project, _name, _Type, _def, _desc) \ /* Fastpath optimization, see notes in FOLLY_SETTINGS_DEFINE_LOCAL_FUNC__. \ Aggregate all off these together in a single section for better TLB \ and cache locality. */ \ __attribute_…

My Ben Eater 8-bit breadboard build

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.…

2 + 2 can be 22

I recently found this well-made short film, Alternative Math, https://www.youtube.com/watch?v=Zh3Yz3PiXZw. It became again after the University of Carlifornia decided to stop using ACT/SAT. I am a father of two young children, and I think everyone, including the teacher in the film, can do…

API for Assigning Timestamp

This is a follow-up post of my previous one about Spanner. There I talked about how Spanner uses TrueTime API to achieve external consistency at global scale and hide sharding and replication from users. In this post, I want to discuss different options of assigning timestamps and their usefulness to…

Notes on the Google Spanner Paper

This is my notes on the paper: Spanner: Google’s Globally-Distributed Database. I will first summarize the paper and try to explain how it works. At the end, I will list my opinion and questions about Spanner. What is Spanner It's a globally replicated database that hides sharding and replication.…

Unary Plus

A few times I ran into the following issue uint8_t a = 0; std::cout << "a = " << a << std::endl; Guess what would it print? a = What happened here is that it printed NULL (0) in ASCII. uint8_t is just a typedef…

Stack overflow

I recently ran into a program crash. There were some mysteries at the beginning of the debugging process. Mysteries Signal handler not called The program crashed with a coredump, according to which, it crashed with SIGSEGV. The mystery is that the code has registered a signal handler, which should get…