[PATCH] Cygwin: pipe: Restore blocking mode of read pipe on close()

Takashi Yano takashi.yano@nifty.ne.jp
Mon Sep 2 13:07:27 GMT 2024


On Mon, 2 Sep 2024 20:49:28 +0900
Takashi Yano wrote:
> On Mon, 2 Sep 2024 13:10:31 +0200
> Corinna Vinschen wrote:
> > On Aug 30 23:15, Takashi Yano wrote:
> > > If a cygwin app is executed from a non-cygwin app and the cygwin
> > > app exits, read pipe remains on non-blocking mode because of the
> > > commit fc691d0246b9. Due to this behaviour, the non-cygwin app
> > > cannot read the pipe correctly after that. With this patch, the
> > > blocking mode of the read pipe is stored into was_blocking_read_pipe
> > > on set_pipe_non_blocking() when the cygwin app starts and restored
> > > on close().
> > 
> > Looks ok to me, but it would be helpful if Johannes could test this as
> > well.
> > 
> > I just wonder if the whole code could be simplified, if we set
> > the pipe to non-blocking only temporarily while reading or writing,
> > while the pipe is blocking all the time otherwise:
> > 
> > - Create pipe blocking
> > 
> > - set_pipe_non_blocking(true);
> >   NtReadFile() or NtWriteFile();
> >   set_pipe_non_blocking(false)
> > 
> > How costly is it to call NtSetInformationFile(FilePipeInformation)
> > for each read/write?
> 
> Good point. I'll try performance test for that idea.

I did perfomance test using dd command:
dd if=/dev/zero ibs=1M count=1K obs=WB | dd ibs=RB obs=1M of=/dev/null status=none
with the patch attached.

[Current master]
WB=1M,RB=1M: 1.6GB/s
WB=1K,RB=1M: 200MB/s
WB=1M,RB=1K: 245MB/s
WB=1K,RB=1K: 170MB/s

[With experimental patch]
WB=1M,RB=1M: 1.5GB/s
WB=1K,RB=1M: 110MB/s
WB=1M,RB=1K: 125MB/s
WB=1K,RB=1K:  95MB/s

With the experimental implementation, the performance degraded quite a bit,
expecially small read/write block size.

-- 
Takashi Yano <takashi.yano@nifty.ne.jp>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 0001-Cygwin-pipe-Experimental-Set-the-default-pipe-mode-b.patch
URL: <https://cygwin.com/pipermail/cygwin-patches/attachments/20240902/2c5014b6/attachment.ksh>


More information about the Cygwin-patches mailing list