Summary
In this chapter, we explored several patterns related to performance.
First, we discussed how global variables hurt performance and the technique of the global constant pattern. We looked into how the compiler optimizes performance by doing constant folding, constant propagation, and dead branch elimination. We also learned how to create a constant placeholder for wrapping a global variable.
We discussed how to utilize the struct of arrays pattern to turn an array of structs into a struct of arrays. The new layout of the data structure allows better CPU optimization and, hence, better performance. We took advantage of a very useful package, StructArrays, for automating such data structure transformation. We reviewed a financial services ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access