4 ms·
Last I checked, field declaration order still mattered to structure size and cache usage because the defacto packing and padding rules preserve the order. I adm
by megameter 5y ago
Last I checked, field declaration order still mattered to structure size and cache usage because the defacto packing and padding rules preserve the order. I admit that I haven't done any C optimization lately so I am curious. It is possible to make this optimization, but it may disrupt codebases that take shortcuts based on an assumed order. And it would be especially difficult to do the analysis of what should take precedence in the cache.
Could you link an example of compilers accommodating these optimizations?
- HugoDaniel 5y agoThe clang documentation on vectorisation has a few examples https://llvm.org/docs/Vectorizers.html#slp-vectorizer https://llvm.org/docs/Vectorizers.html#slp-vectorizer Cache precedence and cache line optimisations are black magic, either you know specifically the cpu that you are targeting, or rely on hopium techniques like cache oblivious algorithms that try to reap some benefits. The baseline is to measure, always, before and after optimisation(s). These "Data oriented design" approaches are very hard to measure and change rapidly because they have a profound impact on a codebase, rarely ever change "just one thing" and they err to the less intuitive and less readable side.