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]
Cellular Network
Basics of Telephone network and Moblity Management Protocol.
Let us assume you are in conversation with someone on your phone while traveling on a train. Currently, your phone is connected to a nearby cellular tower that provides a wireless connection to your phone and transfers voice signals to the other end of the phone call. When you move far away from your current connected cellular tower, do you think the phone will still be connected to the current cellular tower?
[Read More]
Ubuntu Customization
Make your default Ubuntu Environment looks better
How about customizing your new ubuntu installation? Default installation of Ubuntu 18.04 does not come with few things like, a good terminal theme, vim 8, touch-pad gestures for laptop, power management etc. This blog will explore some of the cool tools that we can use to make ubuntu a more convenient for developers.
First lets install zsh + oh my zsh terminal: The combination of zsh and ohmyzsh makes your terminal work really simplified.
[Read More]