4 ms·
> What does "think about your memory layout" mean? Here are some of the typical concerns: - How exactly fields of a record sit in memory, how much room do hey
by nine_k 2y ago
> What does "think about your memory layout" mean?
Here are some of the typical concerns:
- How exactly fields of a record sit in memory, how much room do hey take, taking into account things like padding for aligned access?
- Are related data sit next to each other, and can stay in the CPU cache together while needed?
- Are chaotic memory accesses thrashing the cache?
- Do the data structures avoid gratuitous references / pointer chasing (at least mostly)?
- Are local variables mostly allocated on the stack?
- Does your code avoid heap allocations where possible?
- Do fields in your data structure match a binary format, such as of an IP packet, or a memory-mapped register?
- Are your sensitive data protected from paging out to disk if free RAM is exhausted?
If these questions are not even relevant for your problem domain, you likely are not doing systems programming.