RSSAmplifier

Blog

Andreas Hohmann

Random thoughts on nerdy topics

andreashohmann.comRSS feed ↗13 posts

Latest posts

Async IO with epoll, io_uring, and C++ coroutines

Introduction Project setup Errors File descriptors and sockets HTTP client interface and buffers Blocking HTTP client Epoll HTTP client io_uring io_uring HTTP client io_uring with "manual" state machine Coroutines Coroutine API An async coroutine type (Z) Coroutine handle awaiter io_uring event loop with coroutines HTTP client with io_uring and coroutines Combining coroutines Introduction Why does…

Guile exceptions

Error handling dominates most production programss. While we like to focus on the sunny day scenarios and domain models, in reality most of production code detects and handles the "alternate courses" caused by the myriad of error conditions. The quality of error handling and error messages often makes the difference between an enjoyable and a barely usable system. Good error messages make happy…

Bit Fields in C++

Whether we are dealing with network protocols or device drivers, system-level programming often involves bit fields. As a system programming language, C offers a concise syntax to specify bit fields in C strctures, for example struct CStylePacket { u16 a : 3 ; u16 b : 9 ; u16 c : 2 ; } ; Here and in the following examples we are using the short type names popularized by Rust: using u32 = std ::…

C++, move aside?

I recently read Nicolai Josuttis's book about C++ move semantics . It's an excellent book. Detailed, well organized, and full of good explanations and thoughfully arranged diagrams that present all the intricate details of C++ move semantics as clearly as possible. I didn't expect it, but I would even say that I enjoyed reading this book of about 250 pages about a single C++…

Maglev consistent hashing in Rust

In a paper published in 2016, a group of Google engineers describes Google's network load load balancer called Maglev. This system uses a new (at the time) consistent hashing algorithm to select the target that a packet is sent to. This algorithm is now commonly known as "Maglev consistent hashing" and offered by several load balancers including Envoy . This post explores an implementation of…

Zig structs of arrays

If you want to see the power of Zig's comptime, look no further than MultiArrayList . This collection stores the data of a list of structs in struct of array (SoA) rather than an array of structs (AoS). This technique is a staple of data-oriented design and array-oriented programming (long live APL) as used in high-performance applications such as game engines, scientific computing, and…

Picking a C++ style

After several years in JVM and JavaScript land, I recently started working with C++ again. To catch up on the latest (and exciting) developments such as concepts and coroutines, I've been using C++ for some of my toy projects as well. This naturally raises the question of which style to follow. When coding for an organization, I just accept whatever convention the organization has chosen.…

CMake, the programming language

I remember writing my own Python Makefile generator for C++ and Java projects back in the day and being delighted when Maven emerged as the de-facto standard for Java builds and package management. Other language ecosystems also converged on standard tools such as sbt for Scala or Leiningen for Clojure . New programming languages must have a good build and package management story to be taken…

Infrastructure as data

We say "infrastructure as code", but I think what we really mean is "infrastructure as data". Let me explain. What comes to mind when we think of "infrastructure as code"? What are the benefits we want to gain from the "as code" part? I first think of the way we handle code using version control and continuous integration. The version control system gives us global atomic changes, history, test…

Envoy event dispatcher

Like most high-performance servers, Envoy performs IO asynchronously using event loops on a relatively small number of worker threads. How Does Envoy's implementation work? Where does this functionality live? Libevent Envoy 's event dispatcher uses the libevent library that defines an abstraction layer on top of the platform-dependent asynchronous IO APIs such as epoll on Linux and…

Propagating context using Scala's using/given

We have all seen and used the infamous "context" object. Some information, whether it's the current user's authentication and authorization information or the current transaction, has to be passed through all the nice layers and slices of our software system. It starts small and, if not carefully controlled, becomes a large incoherent grab-bag of data over time. We can try to hide it in…

Envoy factory registry

Envoy is an incredibly flexible proxy server. Almost every aspect of the processing chain from the listeners all the way to the management of the upstream connections is configurable. This is even more impressive given that the configuration can be changed on the fly (by reloading a file or via the xDS API) without restarting the server. Moreover, we are not restricted to Envoy's built-in…

Outerhout's "A Philosophy of Software Design"

I keep my expectations low when buying books on software design. It's hard to write about software without referring to a concreate project or narrower topic. More often than not, any general advice has to be watered down by the various tradeoffs that are unavoidable in real projects. I was therefore pleasantly surprised when I picked up the second edition of John Ousterhout's A…