Bug #69900 [Asn]: Commandline input/output weird behaviour

From: Date: Mon, 06 Jul 2015 12:12:36 +0000
Subject: Bug #69900 [Asn]: Commandline input/output weird behaviour
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-194154@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69900&edit=1 ID: 69900 Updated by: ab@php.net Reported by: nerdbeere2k at gmail dot com Summary: Commandline input/output weird behaviour Status: Assigned Type: Bug Package: *General Issues Operating System: Windows PHP Version: 5.5.26 Assigned To: ab Block user comment: N Private report: N New Comment: @nerdbeere, grateful thanks for the tests. Generally, when you use it from Java, it's more about that the php counterpart doesn't use STDIN directly, so using the stream context. Then it'll use blocking read() on the pipe fd - which is indeed faster. Without it - it'll be going by - peek the pipe - nothing there? sleep - repeat And on Windows it's principally hard to achieve to sleep less than 1ms. Blocking read() is of course faster, but less safe as mentioned earlier. Regarding TCP you could try php.net/stream_socket_server , not sure what to do in Java. Ok then, I'll update the NEWS for PHP7 already, will close the ticket when I backported the timeout improvement (but no stream context, etc., as mentioned) into 5.6. Thanks ) Previous Comments: ------------------------------------------------------------------------ [2015-07-04 10:05:22] nerdbeere2k at gmail dot com Hello ab, First, thanks again, this works pretty good! i was not sure which version to use, so i took this one, which is from the day after your post: http://windows.php.net/downloads/snaps/master/r57881e8/php-master-ts-windows-vc14-x86-r57881e8.zip With this i get these results (using STDIN and STDOUT again, and removed "blocking_pipes" option): >.\php-master\php.exe -f passproc.php hello0 fgets() took 23.000955581665ms hello1 fgets() took 2.0010471343994ms hello2 fgets() took 2.000093460083ms hello3 fgets() took 0.99992752075195ms hello4 fgets() took 2.000093460083ms hello5 fgets() took 1.9998550415039ms hello6 fgets() took 1.0001659393311ms hello7 fgets() took 0.99992752075195ms hello8 fgets() took 2.000093460083ms hello9 fgets() took 0.99992752075195ms With blocking pipes set to true and STDIN + STDOUT it seems to be even faster (about 1ms): >.\php-master\php.exe -f passproc.php hello0 fgets() took 23.001909255981ms hello1 fgets() took 0.99992752075195ms hello2 fgets() took 1.0001659393311ms hello3 fgets() took 0.99992752075195ms hello4 fgets() took 0.99992752075195ms hello5 fgets() took 1.0001659393311ms hello6 fgets() took 0.99992752075195ms hello7 fgets() took 0ms hello8 fgets() took 0.99992752075195ms hello9 fgets() took 1.0001659393311ms I was wondering, if i stopped doing this via the command line and instead set up a socket communication between java <=> php (doing basically the same thing)... could i get rid of that 1ms every call? ------------------------------------------------------------------------ [2015-07-02 19:51:40] ab@php.net @nerdbeere2k, this patch is now landed in master. Additionally i made an adjustment for the normal case. Please check your original case using one of the latest snapshots http://windows.php.net/downloads/snaps/master/ (so no stream context, just STDIN). Thanks. ------------------------------------------------------------------------ [2015-07-01 17:56:33] ab@php.net @nerdbere2k, great, then it's the way so far. I'm waiting for the feedback in #69963 so far (it's same topic), maybe you could help with that as well. The way with pipe blocking reads is dangerous. Using it you're on your own with the dead locks in the pipe :( But anyway, should probably merge this tomorrow. Please don't close this yet, the timeouts on the pipe still have to be revisited in php5. I guess without using blocking reads, they can be decrased to 1-2ms, still better than now. So I'll come back to you once more with this. Thanks. ------------------------------------------------------------------------ [2015-07-01 16:57:29] nerdbeere2k at gmail dot com Hello ab, sorry, i didnt change the stdin initialization stdin! I somehow missed that! However, with it, it runs just fine in both PHP and Java! ------------------------------------------------------------------------ [2015-07-01 16:18:18] ab@php.net Thanks for the quick test. Have you also added the stream context i've mentioned while f'opening the stdin? Please see https://github.com/weltling/php-src/blob/5b8e0aa87849c16906a5e59da2d924d8aaa31b0c/ext/standard/tests/streams/proc_open_bug69900.phpt I even guess it's more about setting the right context to stdin than about the proc_open config. Thanks. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=69900 -- Edit this bug report at https://bugs.php.net/bug.php?id=69900&edit=1

« previous php.bugs (#194154) next »