The Leanpub 60 Day 100% Happiness Guarantee
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
See full terms...
Bought separately
$158.98
Minimum price
$79.00
$139
About the Bundle
About the Books
Your build shouldn’t be the slowest, least understood part of your system.
Most C++ engineers never chose to learn CMake. They inherited a CMakeLists.txt, copied a block to add a dependency, and moved on. Then the clean build hits half an hour, a dependency upgrade breaks three teams, and the release binary behaves differently from the one that passed CI.
This book is for that moment. It isn’t a beginner’s tour of CMake commands. It’s a field manual for fixing real production builds. Every chapter opens with a real-world failure: a version endpoint reporting the wrong commit, two copies of a library in one binary, a CI pipeline that broke without a single commit. Each one is traced back to its cause, and the fix is one you can apply, verify, and keep.
What you’ll learn:
Every chapter ends with a Build Health Ledger, a measured record of what changed in configure time, clean build time, incremental rebuild time, and which problems were removed, along with how each fix was verified. Appendix D gathers every check into one build health checklist you can run against any codebase.
Who it’s for: C++ engineers who already use CMake and want to use it well, and anyone who has just been handed a team’s build and told to make it faster and stop it breaking.
Requirements: CMake 3.28 or later. Features from newer releases, including CMake 4.x, are marked by version.
Your benchmark says 4x faster and production doesn’t move. This book is about why, and how to make your numbers tell the truth.
Most C++ performance advice is folklore: virtual calls are slow, exceptions are free, -O3 beats -O2, more threads means more throughput. Each of these is true on some hardware, for some workloads, some of the time, and teams lose weeks acting on them without measuring. Meanwhile the real costs go unseen: a compiler that quietly deleted the code being benchmarked, a profiler that blamed the instruction after the one that missed cache, a hash table that waits on DRAM twice per lookup, a load test that misses the stalls production clients hit.
Bare-Metal Performance Engineering in C++ teaches the discipline that replaces guesswork with evidence. You’ll learn to write benchmarks the compiler can’t fool, to read hardware counters without being misled by multiplexing or skid, and to use Top-Down Microarchitecture Analysis to find in one run whether code is starved in the front end, losing work to mispredictions, or stalled on memory. Then you’ll apply that method from the compiler out to the kernel, and keep the results in place in production.
The book follows a single realistic workload from start to finish: a request-handling service that parses JSON, looks keys up in a multi-million-entry hash table, and serializes responses. Every chapter ends with a Bottleneck Ledger entry recording the service’s cycles per request, IPC, cache misses, and latency percentiles, the dominant bottleneck at that stage, what changed, and how the change was verified. By the end, the service uses about a third to a quarter of the CPU per request it started with, with a fraction of its original tail latency, and every step of that improvement is shown and justified.
What you’ll learnperf stat, perf record, precise events, call graphs, flame graphs, and differential profiles correctlystd::function, and template bloatThis book is for C++ engineers who own the performance of code that runs in production: backend and infrastructure engineers with latency objectives, library maintainers, low-latency and trading developers, and anyone who reviews pull requests that claim speedups. It assumes you’re comfortable with modern C++ and basic computer architecture terms like caches and pipelines. It doesn’t assume prior experience with perf, assembly, or Top-Down analysis, because each tool is introduced from first principles where it’s needed.
It isn’t an algorithms book. It covers what happens after you’ve chosen the right algorithm, when two implementations of it differ by a factor of five because of how they use the machine.
What makes it differentVTune, AMD uProf, bpftrace, and Perfetto are used in later chapters. Four appendices give quick references for perf, hardware events and Top-Down metrics, compiler flags, and a full benchmarking and profiling checklist.
Most of a large C++ codebase's serious security bugs come from a short list of failures: an index one past the end, a reference kept after its object is gone, a cast that trusts the wrong field, a value nobody initialized, a race on a shared string. Large vendors keep reporting that memory-safety issues make up the majority of their high-severity vulnerabilities. The tools that prevent most of them already exist. Most teams just don't use them every day.
Memory-Safe C++ in Production shows you how to use them every day.
You won't get a lecture on best practices. You'll take one realistic service and harden it from start to finish. relay is a network-facing message gateway with an untrusted input boundary, shared state across threads, hot paths where every check has a cost, and third-party code nobody owns. It ships with eight seeded memory bugs, one or more for each bug class, plus two that aren't listed. Over thirteen chapters you'll find them, fix them so their whole class can't come back, and build the tooling that catches the next one before it reaches production.
Every chapter ends with the Safety Ledger, a running record of what relay now enforces, what detects each bug class, which defects are still open, and what each step cost in measured performance. You always know what changed, what it bought and what it cost.
What you'll learn
What makes this book different
Who it's for
The book is for engineers who ship and maintain production C++: application and systems developers, tech leads, security engineers and platform teams. You should know modern C++. You don't need prior experience with sanitizers, fuzzers or the memory model. Each tool is introduced from first principles before you rely on it.
Four reference appendices come with the book: a sanitizer and hardening flag reference, an undefined behavior catalog, a static analysis check reference and a memory safety audit checklist you can run on your own codebase tomorrow.
our lock-free queue passed every test. It ran clean under ThreadSanitizer for a year. Then it moved to ARM servers and started returning corrupted data, with no crash and no warning.
This book is about that gap between code that runs and code that is correct.
Most lock-free code works because of hardware it was never written for. x86 quietly adds orderings the code never asked for, and test machines rarely stall a thread at the worst possible instruction. This book shows you how to build lock-free C++ that is correct by proof rather than by luck, and how to verify it on every architecture you ship to.
What you’ll learn:
std::hazard_pointer and std::rcu.rr, and porting from x86 to ARM.Every structure ships with complete, compilable modern C++, its stress test, and the deliberate bugs that prove the tests can catch it.
For C++ engineers who will run lock-free code in production, and who need it to be right.
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
See full terms...
We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.
(Yes, some authors have already earned much more than that on Leanpub.)
Learn more about writing on Leanpub
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them
You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!
Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.
Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.