ZFS Snapshots: The case of the vanishing disk usage

 3 Jun 2022

I have a home server that runs on TrueNAS (which is FreeBSD) using ZFS for its storage filesystem. I recently ran into the common issue of not knowing where my disk usage was going, discovered that disk usage accounting for snapshots is more complex than for regular filesystems, and thought I’d write it up. Hopefully others find it helpful and/or enlightening.

Generating integers uniformly distributed over an range

 21 Nov 2021

You may have seen that there was recently a submission to the Swift language’s standard library with an interesting title: “An optimal algorithm for bounded random integers” by Stephen Canon. I found the idea intriguing and this post is a summary of my little expedition into the world of bounded pseudorandom integer generation.

Hidden friends with compile-time benefits

 28 Aug 2021

Recently I’ve been thinking about how I could reduce the compilation time of my C++ code (aren’t we all). I also recently saw some people discussing the so-called “hidden friend” idiom in C++ and its various benefits. One of the claimed benefits of hidden friends is that they simplify the compiler’s job, speeding up compilation. I thought I’d investigate.

FreeBSD Service Configuration: A primer & example

 19 Jun 2021
They say you should blog about problems you’ve solved. So here is a blog post about today’s problem: Figuring out how to configure FreeBSD services. We’ll break down the configuration for a simple service, linking you to all the relevant docs along the way. The service The service we’re setting up is syncthing, which I use to synchronise files across my devices via my home server. It works very well and I wholeheartedly recommend it.

Memory Alignment in 2021

 16 May 2021

I recently saw a small argument on the internet (shocking, I know) about whether it is important to care about memory alignment on modern computing hardware. One party claimed that alignment is not something you need to worry about in 2021 and that code which works to ensure it is correct is just getting in the way. The other party was arguing that such code is an important part of ensuring your program’s correctness.

From G to Fast: A short story about email

 12 Jul 2020
Here’s an opinion you’ve probably heard before: Google has too much reach on the internet. They manage most of the search, most of the email, most of the video content and most of the browsers. In an ideal world where all companies work for the benefit of humankind rather than just their shareholders, this would probably be fine, helpful even. Sadly though, we do not live in such a world. So here is the latest chapter in my meagre effort to depend a bit less on Google and its services.

Implementing DNS: RFCs can be sneaky

 28 Mar 2020
We’ve all seen DNS at work. You probably used it to get to this site (if not then who are you and why do you know the IP for my site off-hand?). But how does it work? Sure there are high-level descriptions of it in most Computer Science courses the world over and certainly the internet has no shortage of hand-waving descriptions. When we get down to the finer details though, how does one really create a client that talks directly to a DNS server to get IP addresses from domain names?

Randomly valuing property: A Machi Koro investigation

 26 Dec 2019

In addition to the various computer-ey things that I do, I also like to play boardgames with my friends sometimes. One such game that I like to play is Machi Koro. Machi Koro will be the topic of today’s post so if you’ve never played it, you may want to watch a lets-play of it or something before continuing.

Fortunes Algorithm (Part 2): Some implementation details

 31 Mar 2018
In my previous post, I gave an overview of how Fortune’s algorithm works. For simplicity’s sake I specifically left out details about implementation and so we’ll cover some of that in this post instead. I spent far longer than I originally intended trying to write my own implementation. The main reason for this is that I was repeatedly delayed by the discovery of yet another edge-case which caused my implementation to fail.

Fortunes Algorithm: An intuitive explanation

 29 Mar 2018

A voronoi diagram is a way of dividing up a space into a set of regions (which we call cells) given a set of input points (which we call sites), such that each cell contains exactly 1 site, and the points inside the cell are exactly those whose nearest site is the one inside that cell.