On 14/06/2024 15:45, Andi Kleen wrote:
Usama Arif <usamaarif642@xxxxxxxxx> writes:
Approximately 10-20% of pages to be swapped out are zero pages [1].
Rather than reading/writing these pages to flash resulting
in increased I/O and flash wear, a bitmap can be used to mark these
pages as zero at write time, and the pages can be filled at
read time if the bit corresponding to the page is set.
With this patch, NVMe writes in Meta server fleet decreased
by almost 10% with conventional swap setup (zswap disabled).
[1] https://lore.kernel.org/all/20171018104832epcms5p1b2232e2236258de3d03d1344dde9fce0@epcms5p1/
But how much did the CPU time increase? Surely the new loop is not free?
-Andi
It is negligible.
For a zero filled page, without zero-fill optimization, the CPU would
have to do page compression in zswap or dispatch write to disk, so this
optimization is just replacing the CPU usage for these tasks with CPU
usage for checking if page is zero-filled. This is the reason why
same-filled optimization was there in zswap. Zswap should focus on
actual compression and this series is just moving the optimization to swap.
For a non-zero filled page, the loop quits the first instance you see
non zero data and checks the last word first, so its likely going to
quite very early on in the loop.