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

From: Date: Sat, 04 Jul 2015 10:05:24 +0000
Subject: Bug #69900 [Fbk->Asn]: Commandline input/output weird behaviour
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-194117@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 User updated by: nerdbeere2k at gmail dot com Reported by: nerdbeere2k at gmail dot com Summary: Commandline input/output weird behaviour -Status: Feedback +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: 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? Previous Comments: ------------------------------------------------------------------------ [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. ------------------------------------------------------------------------ [2015-07-01 16:08:35] nerdbeere2k at gmail dot com Hello ab, thanks again for investing your time into this! I tested the php executable from here http://windows.php.net/downloads/snaps/ostc/69900/php-7.0.0-dev-Win32-VC14-x64.zip with the code from your mail, so that: $process = proc_open(PHP_BINARY.' -f test.php', $descriptorspec, $pipes, null, null, array("blocking_pipes" => true)); and added an fflush($pipes[0]) after the fwrite. However, i somehow can't replicate your test-times... This is what it looks like with "blocking_pipes" => true: >.\php-7.0.0\php.exe -f passproc.php hello0 fgets() took 17.000913619995ms hello1 fgets() took 99.004983901978ms hello2 fgets() took 100.00610351562ms hello3 fgets() took 100.00586509705ms hello4 fgets() took 100.00610351562ms hello5 fgets() took 100.00491142273ms hello6 fgets() took 100.00610351562ms hello7 fgets() took 100.00586509705ms hello8 fgets() took 100.00610351562ms hello9 fgets() took 100.00491142273ms and this is what it looks like with "blocking_pipes" => false (or without setting $other_options at all): >.\php-7.0.0\php.exe -f passproc.php hello0 fgets() took 100.00610351562ms hello1 fgets() took 100.00586509705ms hello2 fgets() took 100.00514984131ms hello3 fgets() took 100.00586509705ms hello4 fgets() took 100.00610351562ms hello5 fgets() took 100.00586509705ms hello6 fgets() took 100.00514984131ms hello7 fgets() took 100.00586509705ms hello8 fgets() took 100.00610351562ms hello9 fgets() took 100.00491142273ms Using this version with java produces the same behaviour. So, somehow like before, after the first two reads. Hope this helps. ------------------------------------------------------------------------ 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 (#194117) next »