Here I will mainly write about what I learned recently, so you can expect tidbits about technology, C++, software development and some occasional system administration trivia.
Modern C++ has many neat RAII-based solutions for managing resources. However, every now and then one needs to manually make sure that some code is run when a resource is not needed anymore. One great solution to this problem is a scope guard. The concept is already very old, however I have surprisingly rarely seen them used (and used them too rarely myself). This article describes the concept, shows how to use it and gives some background on scope guards.
I currently build a piece of software which will need a lot of bog-standard SQL queries against an in-memory database. I was (and am) going with SQLite, but a good friend of mine who Knows About Databases™ told me recently that currently, DuckDB is the hot stuff among in-memory databases - but mainly for complex (read: OLAP) queries.
In this article I explore whether DuckDB or SQLite is the better (read: faster) alternative for my simple queries.
I often encounter variations of the following problem: You are given two or more lists (as
std::vector) of elements and you want to sort them “in parallel”, using one of the lists as
keys. I always found the solutions to these kind of problems to be clunky - but with C++23
(or the excellent
range-v3 library) we get a very elegant way of doing this.
If you build an application that uses large, contiguous amounts of memory, it can increase your performance if you allocate this memory in so-called huge pages. Linux offers you two ways of doing that - a legacy way and a modern way. This article describes the modern way of using huge pages, so called transparent huge pages (THP) and applies the techniques from a previous article to verify that we actually got huge pages. pages.
In fact, CodeChecker is much more than just a front-end to Clang’s Static Analyzer (
here on…) - but using it just to drive
clangsa is already awesome enough that I think you should
use it to hunt for bugs in your C++ projects.
This blog now uses Carl Schwan’s great idea (and code) to add a comment section to this (static) website. The whole thing works by using a Mastodon/Fediverse post as an “anchor” for a comment thread.
std::vector has the interesting property of allowing to be used with incomplete types to a small
degree. However, many legacy (and not-so-legacy) code bases use it in ways which are not allowed
by the standard, and which do start breaking with C++20. In this article I’ll explain the
limitations, a mistake I’ve seen several times now and why this starts breaking now.
When optimizing code for performance, it is often useful to have a very clear idea about what happens in memory. Reducing page faults, cache misses, TLB misses et cetera can be a major factor in speeding up your code. In this post I will demonstrate how you can inspect paging information regarding the memory of your process under Linux.
One C++17 problem I come across every now and then is to determine whether a certain class or
function template specialization exists - say, for example, whether
std::hash<SomeType> can be used. I like to have solutions for these kind of problems in a
template-toolbox, usually just a header file living somewhere in my project. In this article I try
to build solutions that are as general as possible to be part of such a toolbox.
I recently needed to trace some error related to C++17 class template argument deduction and came across some corner cases. In this article, I document what I learned, show some “paradox” cases (which have nice, clean solutions as per the standard) and demonstrate a suspected Clang bug.