Antoine Beaupré wrote...

> It looks like --buffer-size does not do what I would have expected:
> 
> $ strace -e read pv -B 4096 /etc/motd > /dev/null
> read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P\34\2\0\0\0\0\0"..., 
> 832) = 832
> read(3, "# Locale name alias data base.\n#"..., 4096) = 2492
> read(3, "", 4096)                       = 0
> read(3, "\nThe programs included with the "..., 131072) = 286
> read(3, "", 130786)                     = 0
> read(4, 
> "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\300\5\0\0\0\0\0\0"..., 832) = 
> 832
>  286 O 0:00:00 [59,5KiB/s] 
> [===========================================================================================================================================>]
>  100%
> +++ exited with 0 +++

Appearently this hasn't changed, using pv from sid (1.6.0-1):

$ strace -e read pv --quiet -B 4096 /etc/motd > /dev/null
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\320\3\2\0\0\0\0\0"..., 
832) = 832
read(3, "\nThe programs included with the "..., 131072) = 286
read(3, "", 130786)                     = 0
read(3, "", 130786)                     = 0
+++ exited with 0 +++

> I would have expected --buffer-size to change the size of the read()
> system call as well as the internal buffer size.

Additionally, I'd expect the output would be written in chunks of the
given buffer size, obviously it's not:

$ dd if=/dev/zero bs=524288 count=1 status=none | strace -e read,write pv 
--quiet --no-splice --buffer-size 1m >/dev/null
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\320\3\2\0\0\0\0\0"..., 
832) = 832
read(0, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 
131072) = 131072
write(1, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 
131072) = 131072
read(0, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 
131072) = 131072
write(1, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 
131072) = 131072
read(0, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 
131072) = 131072
write(1, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 
131072) = 131072
read(0, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 
131072) = 131072
write(1, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 
131072) = 131072
read(0, "", 131072)                     = 0
+++ exited with 0 +++

(Note the --no-splice, no change if it's not used.)

Expected: Several read operations until the buffer is exhausted (or EOF
on input), then one huge or several consecutive smaller write
operations.

> In fact, I am not
> sure I understand what --buffer-size does at all. :)

Add me.

Some light to shed on this?

    Christoph

Attachment: signature.asc
Description: Digital signature

Reply via email to