Path: csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail From: Robert Elz Newsgroups: gnu.bash.bug Subject: Re: bash sockets: printf \x0a does TCP fragmentation Date: Sun, 23 Sep 2018 16:20:02 +0700 Lines: 55 Approved: bug-bash@gnu.org Message-ID: References: <20180922231240358868037@bob.proulx.com> <20180922111950901701520@bob.proulx.com> <20180921231101307758654@bob.proulx.com> <714e1ba0-0052-2f2b-676d-778f2b7129c1@testssl.sh> <7769.1537667711@jinx.noi.kre.to> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: usenet.stanford.edu 1537694443 1951 208.118.235.17 (23 Sep 2018 09:20:43 GMT) X-Complaints-To: action@cs.stanford.edu Cc: bug-bash@gnu.org To: Bob Proulx Envelope-to: bug-bash@gnu.org In-Reply-To: <20180922231240358868037@bob.proulx.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:3c8:9009:181::2 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com gnu.bash.bug:14643 Date: Sat, 22 Sep 2018 23:51:08 -0600 From: Bob Proulx 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.