- Data structures that are contained within a single cache-line are more efficient.
- Use appropriate containers (e.g. prefer reserved std::vector than std::list)
- Organize your data to avoid alignment holes (sorting your struct members by decreasing size is one way)
- Don’t neglect the cache in data structure and algorithm design
- Use smaller data types
- Beware of the standard dynamic memory allocator, which may introduce holes and spread your data around in memory as it warms up
- Make sure all adjacent data is actually used in the hot loops. Otherwise, consider breaking up data structures into hot and cold components, so that the hot loops use hot data.
- Avoid algorithms and datastructures that exhibit irregular access patterns, and favor linear datastructures.
- Know and exploit the implicit structure of data