Language
https://en.cppreference.com/w/cpp/language
Insights into latest features
https://github.com/andreasfertig/cppinsights
For example, show equivalent source for:
- lambdas
- range-based for loops
- auto
Safe C++
Modules
https://nibblestew.blogspot.com/2023/10/the-road-to-hell-is-paved-with-good.html
Standard library
https://en.cppreference.com/w/cpp/standard_library
Build
Pro tip: CMake debugging
- look at build.make generated files to verify targets are there and all dependencies are correct
Speed-up builds
https://www.figma.com/blog/speeding-up-build-times/
- cut build times by 50%
- avoid unnecessary includes
- IWYU (Include What You Use) tool
- Don’t Include What You Don’t Use (DIWYDU) tool
Use ccache when available
https://invent.kde.org/utilities/konsole/-/merge_requests/26?tab=diffs
Or simpler, if not worrying about diagnostic colors
https://stackoverflow.com/questions/1815688/how-to-use-ccache-with-cmake#24305849
Modern CMake 3.x - best practices
https://gist.github.com/mbinna/c61dbb39bca0e4fb7d1f73b0d66a4fd1
Dependencies using FetchContent
https://eliasdaler.github.io/using-cmake/#manual-management
make “improvements”
https://tech.davis-hansson.com/p/make/
Debugging
Configure C++ toolchain to produce binaries that are highly-debuggable
https://dhashe.com/how-to-build-highly-debuggable-c-binaries.html
Code quality
clang-tidy to modernize C++ codebase
https://www.kdab.com/clang-tidy-part-1-modernize-source-code-using-c11c14/
Project organization
https://github.com/f3d-app/f3d
Project with:
- code formatting
- tests
- code coverage metrics
Project page with great example of:
- GitHub Pages setup
- badges for CI, coverage, downloads, …
- list of contributors with avatars
Useful libraries
fmt
https://vitaut.net/posts/2024/binary-size/
- type erasure
- how to minimize template bloat
cpp-dump
https://github.com/philip82148/cpp-dump
Useful tools
https://github.com/haampie/libtree
- list dynamic lib dependencies (like ldd, but in tree form
Advanced tests
Fuzzing
https://github.com/antonio-morales/Fuzzing101
Performance
Tracing at high level
Magic-trace
magic-trace run -full-execution <binary>
or
magic-trace run -trigger .
See other options:
-multi-thread
-multi-snapshot
-timer-resolution <res>
Perf and speedscope
https://github.com/jlfwong/speedscope
Collect profile data:
echo -1 > /proc/sys/kernel/perf_event_paranoid
perf record -a -F 999 -g -p PID > perf.data
perf script -i perf.data > profile.linux-perf.txt
and visualize .txt with speedscope.
Alternatively, if you have speedscope installed locally:
perf record -a -F 999 -g -p PID > perf.data
perf script -i perf.data | speedscope -
Perfetto UI
For large traces, use separate trace_processor service:
curl -L0 https://get.perfetto.dev/trace_processor
chmod +x trace_processor
./trace_processor --httpd /path/to/trace.pftrace
Memory profiling
https://github.com/milostosic/MTuner
Coz - causal profiler
https://github.com/plasma-umass/coz
Orbit - Hybrid sampling + tracing profiler
- not straightforward to set up
- now maintained by Google?
https://github.com/google/orbit
Benchmarking
https://github.com/sheredom/ubench.h
- microbenchmarks