rsync icon indicating copy to clipboard operation
rsync copied to clipboard

`--files-from` reads 1 byte at a time

Open nh2 opened this issue 3 years ago • 1 comments

Dear maintainer,

using --files-from on a local file while running under strace, I noticed that rsync makes 1-byte-sized read() syscalls (syscalls, not libc functions):

[pid 1311096] read(3</my-filelist>, "/", 1) = 1
[pid 1311096] pselect6(4, [3</my-filelist>], NULL, [3</my-filelist>], {tv_sec=60, tv_nsec=0}, NULL) = 1 (in [3], left {tv_sec=59, tv_nsec=999999180})
[pid 1311096] read(3</my-filelist>, "v", 1) = 1
[pid 1311096] pselect6(4, [3</my-filelist>], NULL, [3</my-filelist>], {tv_sec=60, tv_nsec=0}, NULL) = 1 (in [3], left {tv_sec=59, tv_nsec=999999725})
[pid 1311096] read(3</my-filelist>, "a", 1) = 1
[pid 1311096] pselect6(4, [3</my-filelist>], NULL, [3</my-filelist>], {tv_sec=60, tv_nsec=0}, NULL) = 1 (in [3], left {tv_sec=59, tv_nsec=999999702})
[pid 1311096] read(3</my-filelist>, "r", 1) = 1
[pid 1311096] pselect6(4, [3</my-filelist>], NULL, [3</my-filelist>], {tv_sec=60, tv_nsec=0}, NULL) = 1 (in [3], left {tv_sec=59, tv_nsec=999999729})

Notice the / v a r read()s, that's for /var/..., a line in my-filelist.

Single-byte syscalls carry high overhead, and are usually unintentional. Could a normal buffered read be used?

Thanks!

nh2 avatar Dec 27 '21 16:12 nh2

Yeah, that code is using an old socket read-line routine that does do single-byte reads (even if it is reading the names from a file instead of the socket). It will take a good bit of work to sift through all the early-in-the-transfer code (prior to multi-I/O being enabled) to make it use a better buffered read idiom.

WayneD avatar Jan 02 '22 23:01 WayneD