Go 1.26 ships a new garbage collector called Green Tea. Despite the name, this is not a generational GC — it’s a fundamental redesign of the mark-sweep algorithm that works with memory pages instead of individual objects. The result: 10-40% reduction in GC CPU time. This post covers how it works, why it’s faster, and what the AVX-512 vector acceleration does. 1. The Problem with the Old Mark Phase The current GC spends ~90% of its time in marking. The remaining ~10% is sweep. At least 35% of marking time is wasted on memory access stalls — the CPU is waiting for data from RAM. ...
Hierarchical Data in Databases: From Infinite Comments to Product Categories
How do you store a tree in a flat table? Comments nested infinitely like HackerNews, product categories 10 levels deep, org charts, file systems — they’re all trees. This post compares four patterns for hierarchical data: Adjacency List, Nested Set, Materialized Path, and Closure Table. Each with PostgreSQL and MongoDB implementations, real complexity analysis, and when to use what. The Problem A relational table is flat — rows and columns. A tree is recursive — nodes pointing to children pointing to children. There’s no native “tree” column type. You need to encode the tree structure into flat data, and every encoding has trade-offs between read speed, write speed, and storage. ...
Go GC Internals: How the Garbage Collector Actually Works
Go’s garbage collector is a concurrent, tri-color, mark-and-sweep collector. It runs alongside your application without stopping it for long pauses. This post covers the full picture — the algorithm, the four GC phases, write barriers, the pacer, how the GC cooperates with the scheduler, and what GOGC and GOMEMLIMIT actually control. Based on Go 1.24 runtime. 1. Design Constraints Go’s GC operates under constraints that are different from Java’s or Python’s: ...
Go Scheduler Internals: How Goroutines Actually Get Executed
Every Go developer uses goroutines. Few understand what happens after go func(). This post walks through the Go scheduler’s internals — the GMP model, how goroutines get picked to run, preemption, syscall handling, and the netpoller. Based on Go 1.24 runtime source. 1. Why Go Needs Its Own Scheduler OS threads are expensive. Each one costs ~1MB of stack memory and context-switching between them requires a trip to the kernel. If every goroutine mapped 1:1 to an OS thread, a program with 100k goroutines would need 100GB of stack space before it did any real work. ...
Understanding Index in MongoDB Part 1 🥰
Index is a very popular technique to increase search and sorting performance in databases. This article will explore basic Index concepts, especially in MongoDB. What is Index Index is a very popular technique in databases to increase query performance. Especially when the database has a lot of data, say 10000 records, we can’t linearly scan from 1 to 10000 to find. Index in real life is like when we go to a bookstore to find books, we can’t search sequentially through each book - the bookstore has marked each area by different book types so we can search easily. ...
How to Add Properties to Object in TypeScript 🎉
Have you ever wondered how to add Properties to a predefined Object without getting error “Property ‘x’ does not exist on type ‘y’”? This article will answer that for you. 😁 The Problem interface Student { name: string; age?: number; } const sang: Student = { name: "Sang", }; sang.age = 20; // 👈 Error: Property 'age' does not exist on type 'Student' Some might think just add age directly to Student. That would have a big problem: If only the sang variable has age, it won’t work. Because when adding age to Student, all other Student type variables must also have age. ...
Fetching Issues in Client Component with use 🎉
Let’s explore what use is as well as issues that not everyone knows when using it, how to fix them and code examples 😁 What is USE It is first-class support for Promise in ReactJS. Instead of using await for a promise in async function, we wrap that promise with use: “use is a new React function that accepts a promise conceptually similar to await. use handles the promise returned by a function in a way that is compatible with components, hooks, and Suspense.” ...
Caching with Redis in NodeJS Server 🥰
If you already understand what Redis is, let’s learn more about how servers use caching through Redis, specifically with NodeJS 😉 What is Cache Cache is a buffer memory, stored in memory, so it has very fast access speed. Instead of requesting data from Server and then Server queries to Database, with cache it will return available data immediately, no need to query to Database. How it Works Suppose you own a very busy bubble tea shop, if every customer comes to order and then you make bubble tea, it will take a very long time to serve everyone waiting behind, they may leave because they wait too long. So we have to use a method of making batches of bubble tea and putting them in the fridge, ready for whoever comes. ...
Rush B Redis Basics 💥
Today’s blog will explore the concept of Redis, packaging basic Redis concepts for those who want to quickly understand what it is and how to use it. What is Redis? Redis a.k.a REmote DIctionary Server is an open-source NoSQL database that stores data in Key-Value format, can be used as a database, commonly used as Cache memory working together with other databases. Its strength is storing data in RAM so access speed is super fast. Compared to MySQL, MongoDB, etc., data is stored on hard disk. ...
Streaming in NextJS with ReactJS 🎉
NextJS 13 with ReactJS 18 has enabled a new data fetching mechanism called Streaming. This article will dive into the core of NextJS to understand what it is, how it works, and how to implement it 😊 1. What is Streaming Streaming is a method that allows you to display UI Components progressively instead of waiting for everything to load before showing. Example: 2. The Problem Without Streaming With SSR (Server Side Rendering) in NextJS, we first need to understand how it renders and displays to users. The steps are sequential: ...