Optimising a small real-world C++ application
summary
A configurable C++ converter for COBOL/BCD fixed‑format files becomes usable for disaster‑recovery by profiling and iterative change: uses strace, perf, valgrind/cachegrind and Compiler Explorer to find hotspots, replaces string comparisons with enums, removes runtime division by reading BCD nibbles directly, and switches to memory‑map via Boost iostreams to cut system calls. Measured surprises: mmap drops system time by ~25%, simple loop/formatting fixes give ~4× speedup, a 2‑byte lookup table adds ~10%, and nine incremental versions produce a working, much faster tool.
AI-written summary · about
chapters (13)
- 0:00Introduction to optimizing
- 10:19Performance optimization strategy
- 23:56Initial implementation approach
- 30:26Using Valgrind cachegrind
- 40:50Profiling with perf tools
- 45:24Optimizing string handling
- 51:59Compiler Explorer insights
- 1:00:03Loop and branch optimizations
- 1:08:42Memory mapping input file
- 1:13:09Two-byte translation table
- 1:17:31Template specialization attempt
- 1:21:08Compile-time translation table
- 1:22:58Final optimizations and summary
related talks
24m(Ab)using Compiler Tools
35mAlgorithmic and microarchitecture optimizations of C++ applications
45mPerformance Benchmarking with Celero
49mAlgorithmic and microarchitecture optimizations of C++ applications
49mAn Engineering Approach to Optimising C++
57mLessons from 20 years of Debugging C++ Code
01h 00mMoving Faster: Everyday efficiency in modern C++
01h 30mTuning C++: Benchmarks, and CPUs, and Compilers! Oh My!
