This is an archive of the discontinued LLVM Phabricator instance.

Do not use posix_fallocate because it's slow.
AbandonedPublic

Authored by ruiu on Sep 26 2017, 2:22 PM.

Details

Reviewers
rafael
Summary

posix_fallocate is too slow if your filesystem does not support the
fallocate system call.

That's still harmless if you are creating relatively small files,
or the overhead of creating files takes only a small part of an
entire process, but for lld, the issue is pretty noticeable. lld
can now link an 1.7 GiB executable in about 7 seconds on my machine,
and posix_fallocate takes 1 second. Spending a second on every linker
invocation just to prepare for "disk full" errors doesn't make much
sense.

Event Timeline

ruiu created this revision.Sep 26 2017, 2:22 PM
ruiu updated this revision to Diff 116921.Sep 27 2017, 8:35 PM
  • Use fallocate(2) if available.
ruiu abandoned this revision.Sep 28 2017, 7:45 PM

Thank you for reviewing. But I think my test environment was not set up correctly. While it is an ext4, fallocate(2) returned an error. After mkfs'ing the partition, fallocate(2) started working, and the original code worked as fast as with this patch. So it seems there's no point to submit this patch. I'll withdraw it.