Blog

Optimizing a Spin-Lock -- David Álvarez Rosa

From a naive exchange loop to a spin-lock 5.7x faster drawing 5.4x less energy, with benchmarks, assembly, and perf counters at each step.

Optimizing a Spin-Lock

by David Álvarez Rosa

From the article:

A spin-lock is a lock that never sleeps. Instead of yielding to the scheduler, the thread stays on the CPU and spins. No syscalls. No context switches.

In this post, we’ll build a version, step by step, that is 5.7x faster while drawing 5.4x less energy.

Making sense of std::execution -- Mateusz Pusz

Threads, std::future, callbacks, and coroutines each answer part of asynchronous C++, and none of them compose. This is the opening article of a series on std::execution, the C++26 model for asynchronous, composable, cancellable work: what each earlier tool stops short of, what the new model actually is, and where the series goes from here.

Making sense of std::execution

by Mateusz Pusz

From the article:

At its core a sender is a value that describes work without starting it. You compose senders with algorithms into a pipeline, and the pipeline stays lazy until you explicitly run it.

Because the whole computation is a value up front, the things that were afterthoughts in every model above, where each step runs, what happens on error, and how the whole thing is cancelled, become first-class properties of that value. And coroutines are not left behind: they plug into the same model, so the readable co_await front end finally gets a real back end.

Published so far:

Hands-on workshop on September 30: Building Safer Firmware in Modern C++ -- Mateusz Pusz

A live, half-day, hands-on workshop on encoding the meaning of firmware values into the type system, so unit mixups, argument swaps, and out-of-range configuration become compile errors rather than field failures.

Building Safer Firmware in Modern C++, a live workshop with Packt

by Mateusz Pusz

The details:

  • Wednesday 30 September 2026, 15:00 to 19:30 CEST (09:00 to 13:30 EDT), live online, hosted by Packt.
  • Strong types and physical quantities with mp-units turn unit, bounds, and interface mistakes into compile errors. The generated assembly is then read to confirm the safety costs nothing at runtime.
  • Everything runs in the browser on Compiler Explorer, so there is nothing to install.
  • Tickets on Eventbrite.

Two half-day C++ masterclasses, and an open vote on the next online cohort -- Mateusz Pusz

Two half-day live online classes on topics experienced C++ engineers most often ask to revisit, plus an open vote that decides the subject of the next full-length online cohort.

Live online C++ masterclasses and open cohorts

by Mateusz Pusz

The details:

  • Move Semantics and Forwarding References, Sunday 4 October 2026, 15:00 to 19:00 CEST. Value categories, move semantics, forwarding references, reference qualifiers, and the pitfalls around them.
  • Name Lookup, Overload Resolution, and Customization Points, Sunday 6 December 2026, 15:00 to 19:00 CET. ADL, hidden friends, and the rules that decide which overload wins.
  • Both run four hours live for up to 30 attendees, with hands-on exercises in Compiler Explorer and shared solutions reviewed in front of the room. EUR 99 plus VAT.
  • The next open cohort is chosen by vote, open until 11 December 2026, between Advanced Modern C++ (5 days), Modern C++ Concurrent and Asynchronous Programming (4 days), Introduction to C++20 (5 days), and Mastering C++ Coroutines (2 days). The winning subject runs from Monday 22 February 2027.

CppCon 2026: Awaiters and Awaitables -- Mateusz Pusz

Registration is now open for CppCon 2026! The conference starts on September 12 and will be held in person in Aurora, CO. To whet your appetite for this year’s conference, we’re posting some upcoming talks that you will be able to attend this year. Here’s another CppCon future talk we hope you will enjoy – and register today for CppCon 2026!

Awaiters and Awaitables

Wednesday, September 16 09:00 - 10:00 MDT

by Mateusz Pusz

Summary of the talk:

C++20 coroutines come with a reputation for complexity — and writing your own coroutine return type deserves that reputation. But here is the good news: you probably don't have to. With std::generator in C++23, high-quality libraries like Asio and cppcoro today, and std::task on its way in C++26, most developers can simply write co_await and move on.

There is one gap, however. Sooner or later, every developer using coroutines needs to bridge an existing asynchronous interface — a timer, an I/O operation, a thread pool callback, a legacy future — into the coroutine world. That bridge is built with awaiters and awaitables, and that is exactly what this session teaches.

We will start from first principles: what does co await actually do? We will demystify the three functions that form the awaiter protocol — await ready, await suspend, and await resume — and build a clear mental model for each. We will implement a real awaiter from scratch, then explore how symmetric control transfer keeps the call stack flat across deeply chained async operations. Next, we will learn how to make any existing type co await-able without modifying it, using operator co await, and how await transform lets you restrict or adapt awaitable behavior to a specific coroutine context. Finally, we will look at how to write cancellation-aware awaiters using std::stop token, so your coroutines respond promptly when work is no longer needed.

No prior coroutines experience is assumed. If you know what co await looks like on the surface but not what happens underneath it, this session is for you. You will leave with both the knowledge and the code to wrap any asynchronous operation into a first-class co await expression.

CppCon 2026: Graphics Programming with SDL 3 Part 2 -- Mike Shah

Registration is now open for CppCon 2026! The conference starts on September 12 and will be held in person in Aurora, CO. To whet your appetite for this year’s conference, we’re posting some upcoming talks that you will be able to attend this year. Here’s another CppCon future talk we hope you will enjoy – and register today for CppCon 2026!

Graphics Programming with SDL 3 Part 2

Monday, September 14 16:45 - 17:45 MDT

by Mike Shah

Summary of the talk:

Last year I introduced the SDL3 library which provides a solution for building games and graphical applications on multiple platforms. In this talk, we will continue our journey into SDL3, which newly includes the ability to write shaders within the built-in 2D API. My goal is to get you up and running fast by building out a small game application. Throughout the talk I will show how to build a small 2D framework, discussing design decisions and which C++ features can be used to help organize our code. Attendees will leave this talk ready to build multimedia / game applications and with an understanding on if SDL3 is the right tool for them.

Mike Shah is currently a teaching faculty at Yale University with primary teaching interests  in computer systems, computer graphics, and game engines. Mike's research interests are related to performance engineering (dynamic analysis), software visualization, and computer graphics. Along with teaching and research work, Mike juggles occasional consulting work as a 3D Senior Graphics Engineer in C++ and producing programming content at his YouTube channel https://www.youtube.com/@MikeShah

Why We Should Double-Check the AI Output: A Bug Which Wasn’t -- Giovanni Dicanio

AI offers powerful tools for programmers. But should we completely trust the AI-generated output? Let's take a look at a concrete example.

Why We Should Double-Check the AI Output: A Bug Which Wasn’t

by Giovanni Dicanio

From the article:

Recently I asked Claude to review the code of my WinReg C++ library. [...]

As a result of its analysis, Claude reported that there were zero-length bugs in my code, in particular Claude stated that zero-length REG_SZ/REG_EXPAND_SZ values crash the GetStringValue, GetExpandStringValue, TryGetStringValue and TryGetExpandStringValue methods of the RegKey class.

In particular, Claude noted that I correctly guarded against dataSize == 0 in the binary-returning getters (like RegKey::GetBinaryValue), but the string getters do not have such guard.

 

CppCon 2026 Keynote: C++: Growing in a World of Efficiency, Safety, and AI -- Herb Sutter

Registration is now open for CppCon 2026! The conference starts on September 12 and will be held in person in Aurora, CO. To whet your appetite for this year’s conference, we’re posting some upcoming talks that you will be able to attend this year. Here’s another CppCon future talk we hope you will enjoy – and register today for CppCon 2026!

C++: Growing in a World of Efficiency, Safety, and AI

Friday, September 18 16:15 - 18:00 MDT

by Herb Sutter

Summary of the talk:

C++ is adding major expressive power (e.g., reflection) and addressing weaknesses (e.g., memory safety hardening) at exactly the moment when chip supply and power budgets are raising the value of what people came to C++ for in the first place: control over memory layout (space) and deterministic performance (time). This talk is about that convergence, in two parts.

First, we cover the latest developments in ISO C++ itself, where the committee completed technical work on C++26 in March 2026, and then in June voted the first additions into the working draft for C++29:

  • Key C++26 language improvements like reflection and the initial round of memory safety hardening, and standard library performance enhancers like std::simd and std::execution.
  • A new Annex in the C++29 working draft cataloging every case of core language undefined behavior, the first step toward addressing it systematically rather than one paper at a time.
  • Draft “profiles” for stronger portable memory safety guarantees, now being prototyped and targeted at C++29.

Second, we consider how quickly both hardware and software are moving in the industry around us. This year, capital is pouring into silicon and power at a jaw-dropping rate, and agentic systems are arriving with new capabilities and new failure modes. We’ll see how both affect C++ programming in the trenches:

 

  • Why performance efficiency has been enduringly important, from the 1940s through to today and with no end in sight.
  • How current industry data (SlashData, IDC) documents sustained growth in demand for professional programmers, especially who know languages that can operate under real space and time constraints.
  • What AI does and doesn’t change about any of it: a pragmatic view both of where AI has shown real benefit in our programming world, and of what it’s not good at (yet, or ever).

Throughout, we might hear a little grumbling from the speaker about how he has always written his own talk titles and abstracts and prose using em-dashes, but now can’t use em-dashes anymore because of, well, you know.

Herb is a technical fellow at Citadel Securities, designer of several Standard C++ features, chair emeritus of the ISO C++ committee, and chair of the Standard C++ Foundation.

CppCon 2026 Keynote: The Address is Not The Place: Object Residency in C++26 -- Laurie Kirk

Registration is now open for CppCon 2026! The conference starts on September 12 and will be held in person in Aurora, CO. To whet your appetite for this year’s conference, we’re posting some upcoming talks that you will be able to attend this year. Here’s another CppCon future talk we hope you will enjoy – and register today for CppCon 2026!

The Address is Not The Place: Object Residency in C++26

Thursday, September 17 10:30 - 12:00 MDT

by Laurie Kirk

Summary of the talk:

Random Access Memory is what you buy when you don’t know what your program will do next.

Until recently, alternative tiers of memory with vastly different latency characteristics were largely speculative. Then DRAM got expensive. CXL memory pools, far memory, even high bandwidth flash moved from blips to serious contenders. C++ has grown its vocabulary for ownership (smart pointers) and lifetimes (RAII); but intelligent memory tiering, specifically object residency, is a word we don’t natively have.

Attempts have been made to solve this issue at an OS-level (Meta’s TPP), or even a compiler/runtime level (OBASE) but they approach the problem transparently by design. And thus…blind by design. You can improve tiered object locality with clever placement within pages, but all these methods are structurally incapable of predicting intent. What if the power was in the developer’s hands?

With reflection (P2996) and annotations (P3394), C++26 finally lets us extend the vocabulary ourselves. Game developers have deeply understood smart data grouping for decades, but much of the work is locked behind game engines; not suitable for general application development. [[likely]] and [[unlikely]] hint hot and cold paths, but the future of high-performance development hints at general purpose object residency to tier-aware allocators.

This talk introduces an open-source C++26 residency library, demonstrating capabilities against current, and even (simulated) future hardware. The pieces are in place for C++ to create durable abstractions for object residency; with the flexibility to accommodate memory tiers that have not been invented yet!

Laurie Kirk is a researcher at Google specializing in C++, reverse engineering, and deobfuscation. She runs a YouTube channel (@LaurieWired) that covers all sorts of in-depth research topics on reverse engineering, programming, and software optimizations. She has spoken at multiple conferences including ACCU on Sea, Strange Loop, DEFCON, REcon, and Objective by the Sea.

CppCon 2026 Keynote: C++: Profiles for Simplicity and Guarantees -- Bjarne Stroustrup

Registration is now open for CppCon 2026! The conference starts on September 12 and will be held in person in Aurora, CO. To whet your appetite for this year’s conference, we’re posting some upcoming talks that you will be able to attend this year. Here’s another CppCon future talk we hope you will enjoy – and register today for CppCon 2026!

Profiles for Simplicity and Guarantees

Monday, September 14 08:30 - 10:15 MDT

by Bjarne Stroustrup

Summary of the talk:

The C++ community is growing fast. C++ is being used in critical applications. C++ can be used in ways that ensures correctness, simplicity, performance, and maintainability. How can we ensure that it is used is such desirable ways? How can we teach new and old C++ developers to do so?

The general strategy is called “subset of superset” and is based on the idea that by extending (“supersetting”) by adding libraries, we can simplify static analysis to where we can remove undesirable uses (“subsetting”) without damaging expressiveness or efficiency. Where run-time checks are necessary, such as to catch out-of-range accesses in hardened libraries, static analysis can be used to minimize the number of checks.

The strategy is supported by the “Profiles” framework, that allows us to require or suppress specific sets of guarantees, called profiles.

As examples, I show how to eliminate uninitialized-object errors and container-invalidation errors (a kind of dangling pointer errors) using the profiles framework and implementations of the “Initialization” and “invalidation” profiles. Both with zero run-time cost.