C++ Caching & Data Structure and Algorithm Optimizations is a book for C and C++ software engineers looking for advanced efficiency optimizations from the low-level hardware caches to building your own caches and precalculation optimizations at the algorithm and data structure level.
Highlights - Precalculate an entire lookup table or perfect hash lookup. - Modern C++ metaprogramming versions of search space exploration - Source code pre-generation for offline compute in C code.
Table of Contents:Part Caching & Precomputation Introduction
1. Introduction to Caching & Precomputation
2. Theory of Caching & Precomputation
3. Lookup Table Precomputation
Part Compile-Time Precomputation
4. Metaprogramming Precomputation
5. Text File Embedding
6. Source Code Generation
7. Data Structure Unrolling
8. Unrolled Binary Search
9. Switch Multiway Branch Optimizations
10. Computed Goto Jump Tables
Part Algorithm Caching & Precomputation
11. Runtime Auxiliary Precomputation
12. Cache Locality
13. Cache Warming
14. Prefetching
15. LRU Cache Data Structure
16. Deferred Computation
17. Mathematical Algebraic Calculations
Part Precomputed Data Structures
18. Perfect Hashing
19. Old-Style Perfect Hashing in C
20. Prefilled Fixed-Size Data Structures
21. Loop Unrolling
22. Preallocated Memory Pools
23. Bloom Filters
Part General Compile-Time Techniques
24. Compile-Time Optimizations
25. Inline Functions
26. Recursion Flattening
Part General Efficiency Optimizations
27. Branchless Coding Techniques
28. Branchless Conditional Tests
29. Branchless Pitfalls
30. String Optimizations
Part LLM Caching & Precomputation Research
31. LLM Caching Research Overview
32. Semantic Caching
33. KV Caching Overview
34. Prefix KV Caching
35. Radix Trees
36. Non-Prefix KV Caching
37. FFN Fusion
38. FFN Folding
39. Vocabulary Trimming
40. LLM Kernel Synthesis
41. Weight Precomputation Research
Appendices
Appendix Long List of Low Latency Techniques
Appendix B. 500 LLM Inference Optimization Techniques