Hacking Go's Garbage Collector: Pointer Stores from Assembly

2025-06-23
Hacking Go's Garbage Collector: Pointer Stores from Assembly

This post delves into the intricacies of manipulating Go pointers from assembly code, focusing on the crucial interaction with Go's garbage collector. Directly manipulating pointers requires explicitly informing the GC via functions like `runtime.gcWriteBarrier2` and `runtime.writeBarrier` to avoid conflicts and potential crashes. The article also tackles the challenge of allocating 128-bit aligned memory for optimal AVX instruction usage, presenting a clever workaround. However, it warns against relying on internal runtime functions, as their availability might change in future Go versions.

Read more
Development Go assembly

Pushing the Limits of Linux Pipes: From 3.5GiB/s to 62.5GiB/s

2025-06-22
Pushing the Limits of Linux Pipes: From 3.5GiB/s to 62.5GiB/s

This post explores the implementation of Unix pipes in Linux by iteratively optimizing a test program that writes and reads data through a pipe. Starting with a simple program achieving around 3.5GiB/s throughput, the author improves its performance twentyfold through several optimization stages. Key improvements include utilizing `vmsplice` and `splice` system calls to eliminate data copying, leveraging huge pages to reduce paging overhead, and employing busy-looping to minimize synchronization costs. The journey is detailed with code examples and performance analysis using Linux's `perf` tool.

Read more
Development Pipes