Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #14643 > unrolled thread

Re: bash sockets: printf \x0a does TCP fragmentation

Started byRobert Elz <kre@munnari.OZ.AU>
First post2018-09-23 16:20 +0700
Last post2018-09-23 16:20 +0700
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: bash sockets: printf \x0a does TCP fragmentation Robert Elz <kre@munnari.OZ.AU> - 2018-09-23 16:20 +0700

#14643 — Re: bash sockets: printf \x0a does TCP fragmentation

FromRobert Elz <kre@munnari.OZ.AU>
Date2018-09-23 16:20 +0700
SubjectRe: bash sockets: printf \x0a does TCP fragmentation
Message-ID<mailman.1168.1537694443.1284.bug-bash@gnu.org>
    Date:        Sat, 22 Sep 2018 23:51:08 -0600
    From:        Bob Proulx <bob@proulx.com>
    Message-ID:  <20180922231240358868037@bob.proulx.com>

  | Using the same buffer size
  | for input and output is usually most efficient.

Yes, but as the objective seemed to be to make big packets, that is probably
not as important.

  |   $ printf -- "%s\n" one two | strace -o /tmp/out -e write,read dd status=none obs=1M ; cat /tmp/out
  |   one
  |   two
  |   ...
  |   read(0, "one\ntwo\n", 512)              = 8

What is relevant there is that you're getrting both lines from the printf in 
one read.  If that had happened, there would ne no need for any rebuffering.
The point of the original complaint was that  that was not ahppening, and
the reads were being broken at the \n ... here it might easily make a 
difference whether the output is a pipe or a socket (I have no idea.)

  | But even if ibs is much too small it still behaves okay with a small
  | input buffer size and a large output buffer size.

Yes, with separate buffers, that's how dd works (has always worked).
That is why using it that way could solve the problem.

  | It seems to me that using a large buffer size for both read and write
  | would be the most efficient.

Yes.

  | It can then use the same buffer that data was read into for the output
  | buffer directly.

No, it can't, that's what bs= does - you're right, that is most effecient,
but there is no rebuffering, whatever is read, is written, and in that case
even more effecient is not to interpose dd at all.  The whole point was
to get the rebuffering.

Try tests more like

	{ printf %s\\n aaa; sleep 1; printf %s\\n bbb ; } | dd ....

so there will be clearly 2 different writes, and small reads for dd
(however big the input buffer has) - with obs= (somethingbig enough)
there will be just 1 write, with bs= (anything big enough for the whole
output) there will still be two writes.

kre

ps: this is not really the correct place to discuss dd.

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web