Open gerion0 opened 1 year ago
We do use it when available. https://github.com/Tookmund/Swapspace/blob/9342d856ccc4c382c0c624e985d9c2b7b9fd9f57/src/swaps.c#L418
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.
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.