Clarify our use of `fallocate` vs just writing bytes
gerion0 opened this issue · 2 comments
Currently, the swap files seem to be allocated by opening a file and writing zeros in it (with fill_swapfile
/write_data
). This takes a lot of time and normally has no real benefit, since the data is overwritten anyway.
For these cases, Linux and glibc provide the fallocate
-call, which instantly can allocate a large block of data (and is supported on all major file systems and usable for swap files).
I think, this syscall would be much better suited for this program, since the time to allocate swap would basically disappear completely.
We do use it when available.
Line 418 in 9342d85
The comment above write_data does not make that clear however, and the name itself is now misleading.
Definitely some comment and naming improvements that could be made to clarify it.
Ah nice! I have completely overlooked that block.
Could be, that some more comments are helpful or renaming of write_data
. Anyway, I have searched explicitely for how the file is allocated and scanned for a loop thus missing the codeblock above it. From my side, the bug can be closed.