Caching

Cache Line

http://www.nic.uoregon.edu/~khuck/ts/acumem-report/manual_html/ch03s02.html#:~:text=The%20chunks%20of%20memory%20handled,determined%20by%20the%20cache%20size.

https://stackoverflow.com/questions/3928995/how-do-cache-lines-work

Modern PC memory modules transfer 64 bits (8 bytes) at a time, in a burst of eight transfers, so one command triggers a read or write of a full cache line from memory.

  • So in total, we have 8bytes * 8 = 64 bytes at a time sent

This is from memory → cache

See Memory Alignment

https://x.com/seatedro/status/1874668513719464056/photo/1

  • This is bad for example, because you would need to read the struct 3 times, as opposed to twice if you had written it

“The better question would be to not tell them that anything is wrong, rather ask them what the size of this struct is in memory, whether or not it is possible to reduce its memory footprint, if possible how can you reduce the memory footprint of the struct, and the performance implications alignment has when it comes to program execution”

struct {
    a: u32,
    b: u64,
    c: u32,
}
struct {
    a: u32,
    b: u32,
    c: u64,
}