A Development Journal

Contains the notes and ramblings from my various programming activities.

Faster Protocol Buffer Serialization

Performance is key when building streaming gRPC services. When you’re trying to maximize throughput (e.g. messages per second) benchmarking is essential to understanding where the bottlenecks in your application are. However, as a start, you can pretty much guarantee that one bottleneck is going to be the serialization (marshaling) and deserialization (unmarshaling) of protocol buffer messages. We have a use case where the server does not need all of the information in the message in order to process the message....

May 3, 2023 · 4 min · 642 words · Benjamin Bengfort

Atomic vs Mutex

When implementing Go code, I find myself chasing increased concurrency performance by trying to reduce the number of locks in my code. Often I wonder if using the sync/atomic package is a better choice because I know (as proved by this blog post) that atomics have far more performance than mutexes. The issue is that reading on the internet, including the package documentation itself strongly recommends relying on channels, then mutexes, and finally atomics only if you know what you’re doing....

November 26, 2022 · 2 min · 280 words · Benjamin Bengfort

Nonlinear Workflow for Planning Software Projects

Good software development achieves complexity by describing the interactions between simpler components. Although we tend to think of software processes as step-by-step “wizards”, design and decoupling of components often means that the interactions are non-linear. So why should our software project planning be defined in a linear progression of steps with time estimates? Can we plan projects using a non-linear workflow that mirrors how we think about component design? The figure above is an experiment in task planning that I recently used to try to describe the complex dependencies between different tasks in a project....

March 14, 2021 · 4 min · 680 words · Benjamin Bengfort

Go Closures & Interfaces

Strict typing in the Go programming language provides safety and performance that is valuable even if it does increase the verbosity of code. If there is a drawback to be found with strict typing, it is usually felt by library developers who require flexibility to cover different use cases, and most often appears as a suite of type-named functions such as lib.HandleString, lib.HandleUint64, lib.HandleBool and so on. Go does provide two important language tools that do provide a lot of flexibility in library development: closures and interfaces, which we will explore in this post....

February 23, 2021 · 18 min · 3688 words · Benjamin Bengfort

New Hugo Theme

A facelift for Libelli today! I moved from Jekyll to Hugo for static site generation, a move that has been long overdue — and I’m very happy I’ve done it. Not only can I take advantage of a new theme with extra functionality (PaperMod in this case) but also because Hugo is written in Go, I feel like I have more control over how the site gets generated. A lot has been said on this topic, if you’re thinking about migrating from Jekyll to Hugo, I recommend Sara Soueidan’s blog post — the notes here are Libelli specific and are listed here more as notes than anything else....

January 24, 2021 · 3 min · 626 words · Benjamin Bengfort

Documenting a gRPC API with OpenAPI

gRPC makes the specification and implementation of networked APIs a snap. But what is the simplest way to document a gRPC API? There seem to be some hosted providers by Google, e.g. SmartDocs, but I have yet to find a gRPC-specific tool. For REST API frameworks, documentation is commonly generated along with live examples using OpenAPI (formerly swagger). By using grpc-gateway it appears to be pretty straight forward to generate a REST/gRPC API combo from protocol buffers and then hook into the OpenAPI specification....

January 21, 2021 · 6 min · 1197 words · Benjamin Bengfort

Self Signed CA

I went on a brief adventure looking into creating a lightweight certificate authority (CA) in Go to issue certificates for mTLS connections between peers in a network. The CA was a simple command line program and the idea was that the certificate would initialize its own self-generated certs whose public key would be included in the code base of the peer-to-peer servers, then it could generate TLS x.509 key pairs signed by the CA....

December 30, 2020 · 1 min · 178 words · Benjamin Bengfort