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...

Nine books. One discipline. From the build system to the GPU, from the memory model to the async runtime, every layer of production C++ built, measured, and proven. Nothing is true until it has been profiled, fuzzed, and replayed.
Bought separately
$354.97
Minimum price
$149
$199
About the Bundle
Nine books. One complete systems stack in modern C++. All finished.
Most C++ books stop where production starts. They show a build that works on one laptop, a benchmark that measures an empty loop, a queue that passes its tests on x86, and a server that handles ten connections. Then the code meets a real codebase, real load, and a second architecture.
This library starts where those books stop.
Nine complete books follow a production C++ system from the first build to the last token, in the order you would actually need them. Every technique comes with the measurement that proves it, the trade-off it costs, and the failure it prevents.
What's inside
Build it and measure it
Make it correct and concurrent
3. Memory-Safe C++ in Production: Enforce bounds and lifetime safety with hardened libraries, sanitizers, static analysis, and fuzzing.
4. Lock-Free C++ in Production: Master the memory model, hazard pointers, and epoch-based reclamation, and prove concurrent code correct on x86 and ARM.
5. Production C++23/26 Coroutines: Engineer zero-allocation async runtimes with std::generator, std::execution, and structured concurrency.
Make it serve and persist
6. Bare-Metal Network Programming in C++: Build zero-copy io_uring servers with coroutine scheduling and registered buffer pools that hold tail latency under load.
7. Deterministic Storage Engines in C++: Build crash-consistent LSM trees with write-ahead logging and io_uring, and test recovery under simulated power loss.
Make it parallel
8. Production CUDA for C++ Engineers: Optimize warp-level primitives and shared-memory tiling, guided by Nsight.
9. Bare-Metal LLM Inference in C++: Build quantized GEMM kernels and paged KV-cache systems for continuous batching.
How the series works
Every chapter closes with a running ledger that records what changed at that stage, so you can see exactly what each technique bought you. Code is modern C++20/23, with C++26 features marked where they apply, and written to compile. Compiler and library support is stated for every feature that needs it.
Who it's for
You should be comfortable with modern C++ and Linux. These books do not teach syntax.
What you get
Suggested reading order Build it right, measure it right, make it correct, make it concurrent, make it asynchronous, make it serve, make it durable, make it parallel, and put it all together.
Nothing is true until it has been profiled, fuzzed, and replayed.
About the Books
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.
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.
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.
Your coroutines pass every test. Then production load makes the I/O genuinely asynchronous.
A const std::string& parameter dangles. A stack overflows only when the cache is warm. A lost wakeup stalls a pool for fifty milliseconds. A fire-and-forget coroutine crashes the service at shutdown, once every twenty deploys. None of these are compile errors, and none show up in a thread dump, because a suspended coroutine is not on any stack.
This book is about those failures: why they happen, how to reproduce them on demand, and how to build a runtime where they cannot.
What you will build
Over fourteen chapters you build one runtime, piece by piece, and every piece is tested under AddressSanitizer and ThreadSanitizer:
sync_wait, a single-threaded run loop, a thread pool, and a work-stealing scheduler, with the sleep protocol that avoids lost wakeupswhen_all, when_any, async scopes, and fail-fast error propagation that make fire-and-forget impossiblestd::stop_token, deadlines, race-free cancellation, and shielded async cleanupstd::execution, with a phased migration plan for an existing runtimeWhat makes it different
Inside the book
std::generator, ranges composition, elements_of, and where a hand-written iterator still winswhen_all, cancellation, timeouts, lifetimes across suspensionstd::execution: senders and receivers, custom senders, coroutines and senders in both directions, migrationstd::execution algorithm reference, compiler and library support matrix, and a coroutine code review checkliststd::executionYou should be comfortable with templates, move semantics, RAII, the memory model, and threads. This is not an introduction to what coroutines are.
What you will be able to dostdexec, and the standard task, and migrate between them in safe phasesGCC 13+, Clang 17+, or Visual Studio 2022; CMake 3.25+; NVIDIA stdexec for Part V onward. Linux is recommended for ThreadSanitizer and perf.
Your server isn't slow. It's paying a tax on every request, and you can't see it.
You profiled the handler, tuned the hash table and rewrote the JSON serializer, and the p99 still jumps the moment real traffic arrives. That's because most of a request's cost was never in your code. It's in the system calls, the copies, the wakeups, the context switches, and the queue nobody is measuring. Swapping epoll for io_uring won't fix it either, because a completion-based ring needs a different server design.
Bare-Metal Network Programming in C++ is about that design. It builds one production-grade server from start to finish: an HTTP/1.1 front end for an in-memory cache, with keep-alive, pipelining, TLS and clients that misbehave. Every chapter changes one layer and ends with a ledger of what changed: throughput, p50/p99/p99.9 latency, connection capacity, CPU per request, and how each result was verified under load.
This book doesn't use echo servers or skip error handling. The code is C++23 and handles the failures a live server actually hits: partial reads and writes, connection resets, exhausted buffer rings, completion queue overflow, cancellation races, slow clients and malformed requests.
What you'll build and learn
MSG_RING, cancellation that always waits for the kernel, and structured concurrency for safe teardownWho this book is for
It's for backend, infrastructure and systems engineers who build or run proxies, gateways, caches, trading infrastructure or high-connection servers, and who need them fast under real load, not just in a benchmark. You should already know modern C++, sockets and TCP, and have written a non-blocking server before. This book starts where the tutorials stop.
What's inside
About the author
Weston Ashgrove has spent more than a decade building high-performance network infrastructure in C++: low-latency trading gateways, servers holding hundreds of thousands of connections, and the asynchronous runtimes underneath them. He writes about the failures he has personally debugged.
Stop paying the tax. Build the server the kernel was waiting for.
Your engine passed every kill -9 test. Then the power failed, and acknowledged writes were gone.
Book description
Most storage engines don't lose data because of a recovery bug. They lose it because of a missing barrier. The new manifest was written and synced, then renamed into place, and nobody synced the directory. The contents reached the disk. The record of where to find them never did.
Deterministic Storage Engines in C++ is a build-it-yourself guide to an LSM tree where every durability promise names the barrier that provides it, the failure it survives, and the test that proves it.
You build a complete reference engine in modern C++23 on Linux:
This is not a survey of database papers. Each chapter opens with a concrete failure and works through the mechanism that prevents it:
O_DIRECT is not durabilityfsync can never be retriedEvery chapter closes with a Durability and Throughput Ledger covering throughput and latency ranges, read, write, and space amplification, and exactly how durability was verified.
Who it's forfsync and a correct databaseYour kernel runs. Every launch succeeds. The sums are almost right.
That is the worst kind of CUDA bug. It's the warp reduction that relied on lockstep execution the hardware stopped promising. It's the tile size that fit one architecture's shared memory, or the single extra register that dropped a kernel from four blocks per SM to three. Nothing crashes, and you find out weeks later, in a number that is slightly off.
Production CUDA for C++ Engineers is about writing kernels that stay fast and correct across GPU generations, and about the profiling discipline that tells you, with evidence, when they aren't.
It doesn't sell you on GPUs. It assumes you write production C++ already. A GPU is treated as a throughput machine with specific constraints, and every optimization is tied to a profiler metric you can read: sectors per request, wavefronts per shared load, eligible warps per scheduler, the dominant warp stall.
Every chapter opens with a failure you may recognize and ends with a Kernel Ledger: the fraction of peak reached, the occupancy and dominant stall, and how correctness was verified. Every kernel is validated against a CPU reference, with the tolerance stated and derived, not guessed.
You will learn to:
cp.async and TMA, and know why low-occupancy kernels can beat high-occupancy oneswmma to mma.sync to wgmma, use CUTLASS and CuTe, and choose precisions with error bounds you can defendWhat makes it different
Part I: Foundations. The GPU mental model for C++ engineers, SIMT, launch geometry, toolchains and CMake, error handling with RAII, and unified memory.
Part II: The Memory System. Coalescing, vectorized loads, the L1/L2 paths, the bandwidth roofline, bank conflicts and swizzling, tiling, asynchronous copies and TMA, registers, spills, occupancy, and instruction throughput.
Part III: The Execution Model. Warp shuffles, votes, cooperative groups, thread block clusters, divergence, reductions, scans, scoped atomics, histograms, tiled GEMM, tensor cores, CUTLASS and CuTe, and mixed precision.
Part IV: Concurrency and Scale. Streams, overlap, pinned memory, CUDA Graphs, peer-to-peer and NVLink, NCCL, MPS and MIG, and multi-GPU scaling.
Part V: Tools and Correctness. Nsight Systems and Nsight Compute in depth, compute-sanitizer, cuda-gdb, numerical reproducibility, and testing strategies for GPU kernels.
Part VI: Production. Libraries versus custom kernels, API design, fatbins, PTX JIT and NVRTC, stdpar, containers and driver compatibility, DCGM monitoring, Xid handling, and kernel performance regression testing.
Appendices. The CUDA memory and execution model, compute capability reference, an Nsight metrics reference, and a kernel optimization checklist.
Who this book is forNot for you if you need an introduction to C++ or parallel programming. The book assumes both from page one.
PrerequisitesSolid modern C++ (templates, RAII, the memory model). Basic parallel programming. A CUDA-capable GPU (compute capability 8.0 or later is ideal; the book notes where Hopper or Blackwell is needed). CUDA Toolkit 13.x, or 12.8 or later.
Your quantized model passed perplexity. It’s still failing a few percent of your customers’ JSON, and nothing on your dashboard will tell you that.
Most inference engines are built for benchmarks. They post strong numbers on 128-token prompts with one polite client. In production, three things break them:
None of these failures crash anything. Health checks stay green while the output quietly goes wrong.
Bare-Metal LLM Inference in C++ is the engineering manual for the layer underneath LLM serving, the part that turns weights and a prompt into tokens. You build a complete production inference engine in modern C++, from a validated model loader to a streaming server with admission control. Each decision is derived from the hardware, measured against a roofline, and checked against a reference implementation before it is allowed to be fast.
What you’ll buildEvery claim is checkable. Performance figures are given as ranges derived from first principles, never as numbers from benchmarks nobody ran. Every accuracy claim names how it was measured, and every optimization comes with its trade-off stated in the same breath.
The code is real. It is C++20/23 that compiles and handles the failures a live engine actually hits: misaligned buffers, NaNs in activations, integer accumulator overflow, KV-cache exhaustion mid-generation, cancelled requests, and malformed model files. It contains no pseudocode and no “error handling omitted.”
It is written by someone who has debugged these failures. That includes a server that ran out of memory at a fraction of its capacity, a 4-bit model that broke structured output while passing every check, and a dual-socket box that ran slower on twice the threads. Each chapter opens with a failure like these and builds what prevents it. Each chapter closes with the Tokens and Accuracy Ledger, which records what the chapter’s work bought in throughput, latency and memory, and what it cost in accuracy.
Who this book is forThis book is for engineers who will run inference in production:
You should be comfortable with modern C++ and SIMD basics. You don’t need a machine-learning background, because the transformer is introduced only where the engine needs it, and only from the serving side.
If you have ever shipped a speedup and wondered what it broke, this book gives you a way to know.
About the Author
Weston Ashgrove is a systems engineer with more than a decade of experience building high-performance C++ infrastructure. He started in low-latency systems and numerical computing, then moved into performance engineering for compute-heavy workloads. Today he works on the layer underneath large language model serving: inference runtimes, quantized compute kernels, KV-cache memory management, and the schedulers that decide which tokens get computed when. He writes for engineers who have to make systems run correctly in production, not just in a benchmark.
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.