Trying out C++26 executors

I wanted my program to boot up faster so I tried to multithread it with both executors and the more classic TBB.

Back in 2020 I did a remote talk at CppCon about my work on making Stellaris boot up much faster. I later brought similar improvements to Hearts of Iron IV and Europa Universalis IV (although I’m afraid the latter was never pushed to the live branch, you have to opt-in to a beta version). They key to those improvement was, of course, concurrency: put stuff to load in the background if it’s not needed upfront, and use multiple threads to do the work when possible.

Continue reading Trying out C++26 executors

C++ Enum Class and Error Codes, part 2

In our previous article we talked about the limits of using enum class for API error reporting. Today we look at alternatives.

Last week, we showcased how C++11’s enum class can be used for error codes and discussed what is, in my opinion, its biggest limitation: the inability to easily use them in boolean contexts to see if an error did occur. While it was possible to add the functionality, it required some amount of code to write and didn’t generate amazing assembly compared to native types unless we turned aggressive optimizations on.

Continue reading C++ Enum Class and Error Codes, part 2

C++ Enum Class and Error Codes

C++11 gave us enum class and while it’s great to have scoped enums I don’t find it great for error handling. Let’s talk about why.

Most of my readers, I hope, have been able to use C++11 for a while now (if not hello, I’m sorry the world has changed to become this weird during your 14 years sleep). With it came a small change that allowed for better scoping of names without resorting to weird quirks: enum class. The idea is simple: owing to C, enum values in C++ belong to the class or namespace they are declared in but if we add the class keyword to the declaration they know become their own scope instead of leaking to their parent.

Continue reading C++ Enum Class and Error Codes

What makes a game tick? Part 7 - Data Driven Multi-Threading

Let’s talk about game simulations. In this episode we look at different ways to approach task-based parallelism.

During summer we explored some simple multi-threading models. They had the advantage of giving us a migration path for existing code that runs a very serial/imperative simulation. Now is the time to explore what other approaches we could take for a new project, or if we’re willing to refactor a lot of existing logic. Today we look at task-based parallelism.

Continue reading What makes a game tick? Part 7 - Data Driven Multi-Threading

The Performance Spectrum

We take a little break from our “What Makes A Game Tick” series to get a little bit philosophical about the topic of performance and what it means for different people.

I was at CppNorth a month ago and after listening to a few talks and having conversations with fellow speakers and attendees I realized that despite all of us being here because we care about performance to some degree (else we’d all be doing Python or Javascript or something) when it came to nitty-gritty details, I wasn’t sure we were talking about the same thing. And maybe that could explain some of the disconnect I can sometimes observe between various industries talking about using C++ on social media?

Continue reading The Performance Spectrum

Pagination