libbb: use sendfile() to copy data between file descriptors

Busybox already uses sendfile in httpd. This patch proposes to use it
globally to copy data between file descriptors.

It speeds up the copying on slow systems a lot - below are the times needed
to copy a 450Mb file with and without this option enabled on a BeagleBone
Black:

sendfile:
user    0m0.000s
sys     0m8.170s

read/write 4k:
user    0m0.470s
sys     0m16.300s

function                                             old     new   delta
bb_full_fd_action                                    394     474     +80

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Bartosz Golaszewski
2014-11-27 13:20:24 +01:00
committed by Denys Vlasenko
parent ee41094b80
commit 8d75d794ea
4 changed files with 71 additions and 42 deletions

View File

@@ -181,14 +181,6 @@ config FEATURE_HTTPD_RANGES
"Range: bytes=NNN-[MMM]" header. Allows for resuming interrupted
downloads, seeking in multimedia players etc.
config FEATURE_HTTPD_USE_SENDFILE
bool "Use sendfile system call"
default y
depends on HTTPD
help
When enabled, httpd will use the kernel sendfile() function
instead of read/write loop.
config FEATURE_HTTPD_SETUID
bool "Enable -u <user> option"
default y