RSSAmplifier

Blog

Ketan Singh

Recent content on Ketan Singh

ketansingh.meRSS feed ↗10 posts

Latest posts

Limitations of Rust Borrow Checker

Borrow checker is one of the most defining feature of the Rust programming language. We can even say it’s the primary mechanism which makes the language memory safe, while also being of the thing which can frustrate people new to the language because they have to fight the “rules” of the borrow checker. Let me give a quick introduction to these rules as a refresher. All the…

Writing a toy compiler with Go and LLVM

Goal of this post is to take a brief look into LLVM infrastructure and LLVM IR, then use that knowledge to build a toy brainfuck compiler that emits IR which can then further be compiled into native executable by LLVM tools. You can find the full source code in this repository What is LLVM? So what even is LLVM? LLVM Project is a compiler framework and collection of tools which can be used to…

Let's talk SkipList

Background SkipLists often come up when discussing “obscure” data-structures but in reality they are not that obscure, in fact many of the production grade softwares actively use them. In this post I’ll try to go into SkipLists by describing how to make a toy implementation, potential optimizations and real world use cases of them. So what are SkipLists anyway? Well, SkipList are…

How Not to Do Mysql Failover

Prelude This is a story from few years ago when I accidentally messed up the MySQL failover, lost some critical data momentarily, and then managed to recover all the lost data. To begin with, some of you might ask what the heck is failover anyway? In MySQL a replicated cluster is a collective of database nodes where each of them may serve one role at a time (source & replication in MySQL’s…

How Postgres Stores Rows

Out of curiosity, I was trying to understand how PostgreSQL stores the data onto the disk and there are a few interesting things that I have noticed that might be useful for application developers. In this post, I will try to go into the implementation level details and map out how PostgreSQL row storage really works. Just to be clear, PostgreSQL stores a lot of files on disk such as transaction…

Pipeline Pattern in Go Part 2

This post is continuation of older post Pipeline Pattern in Go Part 1. We will try to generalize the pipeline pattern into a library such that it can be used for different use-cases without having to repeat the whole thing everywhere. P.S. You can find source here , You can also see it action on playground Design Principle It’s important to quantize what we want out of this library,…

Pipeline Pattern in Go Part 1

I am going to divide this post into two parts, In the first part I will try to explain basic building blocks of pipelines and in second post I will try to build a general purpose library around this design. I was recently reading Concurrency In Go and came across something called as pipeline processing pattern. Idea is you can break a logical functionality into stages. Each stage does its own…

Speeding up Python with Rust, what works and what doesn't !

P.S. You can find source here What works Not so long ago I encountered lzstring python package which is itself a port from Javascript’s lz-string library. What’s the purpose you ask? Javascipt package was written to compress relatively large amounts of data and store it in localStorage. Depending upon kind of text, its redundancies and compression level of the algorithm I found that it…

The other sync package

I am sure everyone familiar with Go has come across the concurrency primitives at some point which mainly includes goroutines, channels and the sync package which provides us with Mutex, RWMutex, WaitGroup, etc. primarily used for synchronization. In this post I want to draw attention to another useful but less widely known sibling of the sync package, golang.org/x/sync. This particular package is…

Hello world

This blog is supposed to be a place where I hope to put forward thoughts and tricks of the trade I come across during my daily hustle. It is powered by Hugo and is using ezhil theme. Originally I started with hugo-ink theme which is a fork of ezhil and is supposed to be better but as soon as I started working with it, I noticed that explicit dark mode doesn’t works as intended.