Example demos

Seven runnable companions to the tutorial.

Every claim made in the tutorial body has a demo behind it. Each demo is a self-contained Podman project with its own ./demo.sh, its own Containerfile(s), and the CMake / Conan plumbing to build hermetically. Read the matching tutorial section for context, then run the demo from its directory.

Demos

Each card links to the demo's page on this site (a rendering of the README with cross-references), and each page links to the source on GitHub. Each demo also stands alone — run it without reading the tutorial first if you'd rather poke at it directly.

Demo 01 · §4, §5

Image strategy & PGO

UBI multi-stage vs UBI-micro vs single-stage-naive, plus a two-pass PGO build. hey drives load against each variant; the demo prints a p50/p95/p99 table side by side.

Read page →
Demo 02 · §6

STL & layout

unordered_map vs map vs flat_map vs vector with a linear scan; Google Benchmark median timings under a baseline and a 128 MB cgroup memory cap, side-by-side.

Read page →
Demo 03 · §8, §9

io_uring & async gRPC

Direct liburing, an Asio io_uring executor, and an async gRPC server — three servers in one binary. Wired into the LGTM observability stack; ghz drives load and the demo writes results to disk.

Read page →
Demo 04 · §10

Observability stack

A C++ HTTP service instrumented with OpenTelemetry (traces, metrics, logs) running alongside grafana/otel-lgtm. Optional bpftrace probes add the kernel-side dimension above the application telemetry.

Read page →
Demo 05 · §11

Noisy neighbor isolation

Twin-tenant scenario: a latency-sensitive HTTP service next to a CPU/memory-bound noisy neighbor. Compares baseline, unisolated, cpu.weight, and cpuset.cpus pinning.

Read page →
Demo 06 · §7

Memory & allocators

Side-by-side latency comparison of std::allocator, std::pmr::synchronized_pool_resource, and mimalloc on an allocator-stressful workload. Layered with MAP_HUGETLB and cgroup memory.high pressure. OTel-instrumented; histograms reach the LGTM stack.

Read page →
Demo 07 · §12, §13

Quality & ABI pipeline

cppcheck and clang-tidy as build stages, gtest+gmock suite, abidiff against a checked-in ABI reference, plus a gdbserver sidecar for live debugging. Hermetic Conan 2 lockfile + CMake presets throughout.

Read page →

Running every demo

Clone the repo and invoke each demo.sh from its directory. The scripts assume Podman 5.x rootless and a handful of host tools (hey, jq, curl) — see §1 Prerequisites for the full list.

git clone https://github.com/patterncatalyst/cpp-container-optimization-tutorial.git
cd cpp-container-optimization-tutorial/examples/demo-01-image-strategy
./demo.sh
# ... or run them all in sequence:
cd cpp-container-optimization-tutorial
./scripts/test-all-demos.sh

If a demo fails

Most failures are kernel-feature gaps (io_uring multishot needs ≥ 5.19) or rootless cgroup limits. The reconciliation plan tracks every demo's verification state per host class. If your host isn't covered, an entry there is the right contribution.