To build @Richard Harrisonβs answer, the disk structure hasnβt really changed, swap uses the file as swap memory, and βbsβ reads / writes this byte size from the file every time it needs to swap.
From this we can understand that the best "bs" is not a property of the machine, but a property of the algorithm you are using.
For example, if you have 11 bytes of RAM (an unlimited number for the code). You create two arrays of 10 bytes in size. You create a byte for counting. You iterate over each array (second, then first) and print it. then the program ends.
For bs = 10 bytes:
First array nothing happens. In the second array creation, The entire first array goes into swap in **ONE** write operation. The second array is loaded into memory in **ONE** write operation. You print the second array. The second array is freed. The first array is loaded into memory in **ONE** write operation. You print the first array. The first array is freed.
For bs = 5 bytes:
First array nothing happens. In the second array creation, The entire first array goes into swap in **TWO** write operations. The second array is loaded into memory in **TWO** write operations. You print the second array. The second array is freed. The first array is loaded into memory in **TWO** write operations. You print the first array. The first array is freed.
Of course, this is a very simple example, but as you can see, the number of read / write operations is very dependent on the algorithm.
I hope this is helpful. Best of all, Eran.
source share