A Deep Dive into the LSM Tree #1

Understanding LSM Tree using leveldb

I’ve been reading about LSM trees for a while but never really dived into any implementation. I thought of starting with an existing codebase. RocksDB came to mind since I’ve used it before at work, but its codebase is quite large. So, I decided to start with LevelDB, which has a much smaller codebase and, at first glance, looks more straightforward to understand. Before I delve into LevelDB, here’s a brief introduction to LSM trees. [Read More]

Practical Template Meta Programming (Part-1)

Static reflection using Template Meta Programming and Macros

In this blog, we will implement a generic Print(user defined struct) utility function capable of printing all the public members of any user-defined POD struct. For example: // We would like to Print MessageA // which has messageB as member item struct messageA { int a; messageB b; }; // messageB has messageD as member struct messageB { int p; messageD d[3]; }; // struct layout struct messageD { double t; int v; }; and we expect the output as shown below after executing the following program: [Read More]

Tour of Registers

User Space Thead in C++

This is a series of blogs exploring the implementation of User Space Thread in C++. A user-space thread is managed by the userspace code with very minimal involvement of the Kernel APIs. This blog will not discuss the pros and cons of User Space Thread, nevertheless, you might want to check this. I believe that knowing the machinery of User Space Thread implementation will help us to understand the new Coroutine feature released in C++20 (Talk from cppcon 2015). [Read More]

Cpp chronicle #2

C++ template basics - 1

Template is a great C++ language feature, with which we can make classes and functions operate on generic types without actually writing code for all possible valid types. For example std::vector container in C++11 is a template class. We can use it for with different value types, with the following syntax. std::vector<int> v1; std::vector<char> v2; Here, v1 can hold values of type int and v2 can hold values of type char. [Read More]

Cpp chronicle #1

Joinable and interruptible thread in C++20

What are some of the problems with the std::thread ? The following program will cause core dump. /* gcc version 10.0.1 20200314 (experimental) (GCC) Ubuntu 18.04.5 LTS x86_64 GNU/Linux 5.6.2 */ #include <thread> #include <iostream> int main() { std::thread t{[]() { std::cout <<"Hello from thread t"<<std::endl; }}; } The reason for the core dump is std::terminate() called by the destructor of the std::thread object t. // from std::thread header ~thread() { if (joinable()) std::terminate(); } The default terminate handler calls abort. [Read More]
c++  thread