Your photos describe how we (people) visualize computer memory.
In fact, think of memory as a huge matrix of bits. Each column of the matrix has a βreaderβ that can read / write any bit from this column. Each row of the matrix has a βselectorβ that can select a specific bit that the reader will read / write.
Therefore, this reader can immediately read the entire selected row of the matrix. The length of this row (the number of columns in the matrix) determines how much data can be read at once. For example, if you have 64 columns, your memory controller can read 8 bytes at once (usually this can do more than that).
As long as you keep your data aligned, you will need less of these memory accesses. Even if you need to read only two bits, but they are located on different lines, you will need two memory accesses instead of one.
In addition, there is a whole aspect of writing, which is another problem.
Just as you can read an entire line, you can also write an entire line. If your data is not aligned when you write something that is not a complete line, you will need to perform read-modify-write (read the old contents of the line, change the corresponding part and write new content).
source share