Visual representation of Go struct memory layout with gaps indicating padding between fields.

Mind the Gap: Understanding Go Struct Padding

With page layouts and an understanding of page descriptors and mmap in place, I was ready to define the page structure for Mint. Like most things, it started with some basic struct definitions, methods, and interfaces. Everything seemed to be going smoothly. The next step was to map the byte slice returned by mmap into something more meaningful. Since mmap reflects the file content as-is, working with raw bytes directly can be tedious and error-prone, especially as the structure grows. Even with a formal layout in mind, dealing with offsets and manual encoding felt clunky. ...

July 12, 2025 · 4 min · Chirag Chandrashekhar
Diagram of file descriptor to inode mapping with mmap accessing a memory page.

File descriptors and mmap

Recap Before we jump into file descriptors and mmap, here’s a quick recap from the previous post: Pages are fixed-size blocks of memory Page layouts are how data is kept inside those blocks Mint’s page layouts are just what Mint needs for its use cases This is the base we’ll use to understand how files work in the OS. Mainly, we’ll talk about file descriptors and how mmap uses them. File descriptors Every time a process opens a file, the OS returns a number. That number is called a file descriptor, and the process uses it to talk to the file from that point on. ...

July 8, 2025 · 4 min · Chirag Chandrashekhar
A diagram of memory pages with a subtle notebook aesthetic

Pages and Layouts in Mint

Pages Pages are fixed-size blocks of memory. Think of them like pages in a notebook. Each page has a fixed size, and any data written to memory is written to one or more pages. Now let’s take a step back and look at a computer’s memory. There are two types: Persistent (like SSD or HDD) Volatile (RAM) If we want some data to persist even after our program ends or the system restarts, it must be saved in persistent storage. RAM is fast but temporary. The downside with persistent storage is that it’s slower. HDDs used to be slow due to their moving parts. SSDs fixed that, but even now, they’re still slower than RAM. ...

June 29, 2025 · 11 min · Chirag Chandrashekhar