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.