Re: [PHP] Node.PHP

2012-04-03 Thread Joseph Moniz
On Fri, Mar 30, 2012 at 5:56 PM, German Geek geek...@gmail.com wrote:
 Maybe stupid question, but is node.php really necessary? If you can program
 PHP and it performs better than node.js, why would you need to have another
 wrapper around things. Why not just program normal PHP?

This is normal PHP in the same sense that node.js is normal
javascript, python-tornado is normal python and ruby-event-machine is
normal ruby. The only difference as stated by micheal was the async
IO.

On Fri, Mar 30, 2012 at 6:33 PM, Michael Save
savetheinter...@omegasdg.com wrote:
 Also, I kind of doubt you can outperform node.js with standard PHP.

On Sat, Mar 31, 2012 at 9:37 AM, Daniel Brown danbr...@php.net wrote:
 On Fri, Mar 30, 2012 at 21:33, Michael Save
 savetheinter...@omegasdg.com wrote:
 Because normal PHP is not asynchronous.

 Also, I kind of doubt you can outperform node.js with standard PHP.

    Your doubts are indeed well-grounded.  Using node.js (indeed,
 V8-based apps in general) are compiled as native machine code, which
 don't require the added overhead of a parser, such as PHP.

This has been an on the side just for fun project for me mostly and as
such i originally had the same performance assumptions as stated in
this thread. Basically i was writing this to get familar with php
internals and to understand what goes into designing such a system.

You can imagine my surprise when i ran bench marks against the example
server against an equivelant node.js http server and the node.php
implementation was able to respond to twice as many requests per
second (14k req/s) then node.js could (7k req/s). Though i would take
this with a grain of salt as the benchmark is largely unfair seeing
how node.js is much more feature complete and hardend from production
use. Never the less, i was absolutely shocked that this completely
unoptomized and memory leaky node.php implementation i hacked together
in one night was able to run circles around node.js in naive
benchmarks.

So i was absolutely confused to the performance boost with php so i
started poking around asking people in various freenode channels if
they had any hypothesis on why node.php was able to perform against
node.js.

I stumbled across a similar project to create a node.lua
implemantation called luvit ( http://www.luvit.io ) and it also
boasted the same exact performance boost vs node.js, thats is luvit
was able to do 2x the requests as node.js in the same amount of time.

From my exploration on nodes 1/2x performance vs node.php and luvit
(node.lua) it turns out that V8 is fast only when it has to stay in JS
mode. The problem with node like systems is the JS to native code
boundary must be crossed several times to perform IO. So nodejs-core
get's some of it's best performance boosts from reducing the amount of
times JS has to call out to C++. The unfortunate detail is that
node.js like systems get their power from doing lots of IO and every
IO operation has to call out to C/C++ so node.js performance really
drags around this gotcha in V8.

I hold out some hope for native PHP performance tough. If some one
were to invest the time into making a solid JIT based interpreter for
PHP i'm fairly confident based on language characteristics and the
performance characteristics associated with them that a PHP-JIT
implementation would be able to leave V8 in the dust. Mostly due to
explicit lexical scoping in PHP that would offset the Hidden-Class
overhead of V8.

In terms of PHP-JITs Facebook has already done some initial work on
such a VM, they call it, not surprisingly, hip-hop-virtual-machine (
http://www.facebook.com/note.php?note_id=10150415177928920 ) and it
already doing almost no optimizations is closer to performance of
compiled PHP via hiphop then it is to interpreted PHP via the de facto
interpreter.

- Joseph Moniz



  With that
 said, compiling PHP (such as with HopHop) would give at least
 comparable performance results.

    Still, all in all, I would never discourage someone doing a
 'node.php' application.  While its performance may not be quite as
 good speed-wise, that doesn't mean it can't become more robust, more
 generally-applicable, or even just find niche uses.  I've written
 numerous socket servers in PHP for a variety of clients and uses,
 where they made sense (speed of deployment, ease of code-management by
 a number of developers who don't know C, et cetera).  I can easily see
 where this could add value.

 --
 /Daniel P. Brown
 Network Infrastructure Manager
 http://www.php.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Node.PHP

2012-04-03 Thread Joseph Moniz
*bad link in last post

http://luvit.io/


-Joseph Moniz



On Tue, Apr 3, 2012 at 12:16 PM, Joseph Moniz joseph.mo...@gmail.com wrote:
 On Fri, Mar 30, 2012 at 5:56 PM, German Geek geek...@gmail.com wrote:
 Maybe stupid question, but is node.php really necessary? If you can program
 PHP and it performs better than node.js, why would you need to have another
 wrapper around things. Why not just program normal PHP?

 This is normal PHP in the same sense that node.js is normal
 javascript, python-tornado is normal python and ruby-event-machine is
 normal ruby. The only difference as stated by micheal was the async
 IO.

 On Fri, Mar 30, 2012 at 6:33 PM, Michael Save
 savetheinter...@omegasdg.com wrote:
 Also, I kind of doubt you can outperform node.js with standard PHP.

 On Sat, Mar 31, 2012 at 9:37 AM, Daniel Brown danbr...@php.net wrote:
 On Fri, Mar 30, 2012 at 21:33, Michael Save
 savetheinter...@omegasdg.com wrote:
 Because normal PHP is not asynchronous.

 Also, I kind of doubt you can outperform node.js with standard PHP.

    Your doubts are indeed well-grounded.  Using node.js (indeed,
 V8-based apps in general) are compiled as native machine code, which
 don't require the added overhead of a parser, such as PHP.

 This has been an on the side just for fun project for me mostly and as
 such i originally had the same performance assumptions as stated in
 this thread. Basically i was writing this to get familar with php
 internals and to understand what goes into designing such a system.

 You can imagine my surprise when i ran bench marks against the example
 server against an equivelant node.js http server and the node.php
 implementation was able to respond to twice as many requests per
 second (14k req/s) then node.js could (7k req/s). Though i would take
 this with a grain of salt as the benchmark is largely unfair seeing
 how node.js is much more feature complete and hardend from production
 use. Never the less, i was absolutely shocked that this completely
 unoptomized and memory leaky node.php implementation i hacked together
 in one night was able to run circles around node.js in naive
 benchmarks.

 So i was absolutely confused to the performance boost with php so i
 started poking around asking people in various freenode channels if
 they had any hypothesis on why node.php was able to perform against
 node.js.

 I stumbled across a similar project to create a node.lua
 implemantation called luvit ( http://www.luvit.io ) and it also
 boasted the same exact performance boost vs node.js, thats is luvit
 was able to do 2x the requests as node.js in the same amount of time.

 From my exploration on nodes 1/2x performance vs node.php and luvit
 (node.lua) it turns out that V8 is fast only when it has to stay in JS
 mode. The problem with node like systems is the JS to native code
 boundary must be crossed several times to perform IO. So nodejs-core
 get's some of it's best performance boosts from reducing the amount of
 times JS has to call out to C++. The unfortunate detail is that
 node.js like systems get their power from doing lots of IO and every
 IO operation has to call out to C/C++ so node.js performance really
 drags around this gotcha in V8.

 I hold out some hope for native PHP performance tough. If some one
 were to invest the time into making a solid JIT based interpreter for
 PHP i'm fairly confident based on language characteristics and the
 performance characteristics associated with them that a PHP-JIT
 implementation would be able to leave V8 in the dust. Mostly due to
 explicit lexical scoping in PHP that would offset the Hidden-Class
 overhead of V8.

 In terms of PHP-JITs Facebook has already done some initial work on
 such a VM, they call it, not surprisingly, hip-hop-virtual-machine (
 http://www.facebook.com/note.php?note_id=10150415177928920 ) and it
 already doing almost no optimizations is closer to performance of
 compiled PHP via hiphop then it is to interpreted PHP via the de facto
 interpreter.

 - Joseph Moniz



   With that
 said, compiling PHP (such as with HopHop) would give at least
 comparable performance results.

    Still, all in all, I would never discourage someone doing a
 'node.php' application.  While its performance may not be quite as
 good speed-wise, that doesn't mean it can't become more robust, more
 generally-applicable, or even just find niche uses.  I've written
 numerous socket servers in PHP for a variety of clients and uses,
 where they made sense (speed of deployment, ease of code-management by
 a number of developers who don't know C, et cetera).  I can easily see
 where this could add value.

 --
 /Daniel P. Brown
 Network Infrastructure Manager
 http://www.php.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Node.PHP

2012-03-31 Thread Daniel Brown
On Fri, Mar 30, 2012 at 21:33, Michael Save
savetheinter...@omegasdg.com wrote:
 Because normal PHP is not asynchronous.

 Also, I kind of doubt you can outperform node.js with standard PHP.

Your doubts are indeed well-grounded.  Using node.js (indeed,
V8-based apps in general) are compiled as native machine code, which
don't require the added overhead of a parser, such as PHP.  With that
said, compiling PHP (such as with HopHop) would give at least
comparable performance results.

Still, all in all, I would never discourage someone doing a
'node.php' application.  While its performance may not be quite as
good speed-wise, that doesn't mean it can't become more robust, more
generally-applicable, or even just find niche uses.  I've written
numerous socket servers in PHP for a variety of clients and uses,
where they made sense (speed of deployment, ease of code-management by
a number of developers who don't know C, et cetera).  I can easily see
where this could add value.

-- 
/Daniel P. Brown
Network Infrastructure Manager
http://www.php.net/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Node.PHP

2012-03-30 Thread Hiyarli Baba
As like Micheal's said said just keep up alive the project
I was preferes node.js to pho only when i needed send millions of ssl
api requests.
nodejs sends 1k https request in onky 2 second including parsing
required elements from database , check the returned source write to
file

if you want develope / clone more modules for that please start from
http|s.req :p and let me coninue at php

http://stackoverflow.com/a/9199961 my nodejs + php thing

2012/3/22, Michael Save savetheinter...@omegasdg.com:
 Very nice!

 I'll have a proper look at this in the morning, and I'll try it out
 for myself. Looking forward to seeing more development on this.

 Michael

 On Thu, Mar 22, 2012 at 11:40 AM, Joseph Moniz joseph.mo...@gmail.com
 wrote:
 Hey,

 So i had my first Hackathon at work last week and my project was to
 prototype making a node.js clone using PHP instead of V8. So i
 snatched up libuv and joyent's HTTP parser and set off on a 24 hour
 coding spree to get something workable. By the time the sun was coming
 out the next morning the following code was working.

?php

$http = new node_http();

$http-listen(8080, function($request, $response) {
$response-end(yay, super awesome response);
});

nodephp_run();

?

 The C code that powers it was whipped together really fast and is kind
 of hackish as a result. The code has some memory leaks that i haven't
 had time to fully track down yet. Some small portions of the code were
 borrowed from the phode project.

 In a naive benchmark on this simple server VS an equally simple server
 in node.js this implementation already out performs node.js in
 throughput by being able to serve just under 200% the amount of
 requests per second that node.js could. Take that with a grain of salt
 though because node.js has much more feature and is much more hardend
 from production use. I do believe the PHP binary will have some major
 performance gains over V8 as crossing the PHP -- C barrier seems to
 be a much lighter operation then crossing the V8 -- C++ barrier.

 Any help or feedback will be greatly appreciated. The projects source
 code can be found here: https://github.com/JosephMoniz/node.php

 - Joseph Moniz

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Node.PHP

2012-03-30 Thread German Geek
Maybe stupid question, but is node.php really necessary? If you can program
PHP and it performs better than node.js, why would you need to have another
wrapper around things. Why not just program normal PHP?

twitter: geekdenz
Blog: http://www.thheuer.com

On Sat, Mar 31, 2012 at 10:39 AM, Hiyarli Baba root...@gmail.com wrote:

 As like Micheal's said said just keep up alive the project
 I was preferes node.js to pho only when i needed send millions of ssl
 api requests.
 nodejs sends 1k https request in onky 2 second including parsing
 required elements from database , check the returned source write to
 file

 if you want develope / clone more modules for that please start from
 http|s.req :p and let me coninue at php

 http://stackoverflow.com/a/9199961 my nodejs + php thing

 2012/3/22, Michael Save savetheinter...@omegasdg.com:
  Very nice!
 
  I'll have a proper look at this in the morning, and I'll try it out
  for myself. Looking forward to seeing more development on this.
 
  Michael
 
  On Thu, Mar 22, 2012 at 11:40 AM, Joseph Moniz joseph.mo...@gmail.com
  wrote:
  Hey,
 
  So i had my first Hackathon at work last week and my project was to
  prototype making a node.js clone using PHP instead of V8. So i
  snatched up libuv and joyent's HTTP parser and set off on a 24 hour
  coding spree to get something workable. By the time the sun was coming
  out the next morning the following code was working.
 
 ?php
 
 $http = new node_http();
 
 $http-listen(8080, function($request, $response) {
 $response-end(yay, super awesome response);
 });
 
 nodephp_run();
 
 ?
 
  The C code that powers it was whipped together really fast and is kind
  of hackish as a result. The code has some memory leaks that i haven't
  had time to fully track down yet. Some small portions of the code were
  borrowed from the phode project.
 
  In a naive benchmark on this simple server VS an equally simple server
  in node.js this implementation already out performs node.js in
  throughput by being able to serve just under 200% the amount of
  requests per second that node.js could. Take that with a grain of salt
  though because node.js has much more feature and is much more hardend
  from production use. I do believe the PHP binary will have some major
  performance gains over V8 as crossing the PHP -- C barrier seems to
  be a much lighter operation then crossing the V8 -- C++ barrier.
 
  Any help or feedback will be greatly appreciated. The projects source
  code can be found here: https://github.com/JosephMoniz/node.php
 
  - Joseph Moniz
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Node.PHP

2012-03-30 Thread Michael Save
Because normal PHP is not asynchronous.

Also, I kind of doubt you can outperform node.js with standard PHP.

On Sat, Mar 31, 2012 at 11:56 AM, German Geek geek...@gmail.com wrote:
 Maybe stupid question, but is node.php really necessary? If you can program
 PHP and it performs better than node.js, why would you need to have another
 wrapper around things. Why not just program normal PHP?

 twitter: geekdenz
 Blog: http://www.thheuer.com

 On Sat, Mar 31, 2012 at 10:39 AM, Hiyarli Baba root...@gmail.com wrote:

 As like Micheal's said said just keep up alive the project
 I was preferes node.js to pho only when i needed send millions of ssl
 api requests.
 nodejs sends 1k https request in onky 2 second including parsing
 required elements from database , check the returned source write to
 file

 if you want develope / clone more modules for that please start from
 http|s.req :p and let me coninue at php

 http://stackoverflow.com/a/9199961 my nodejs + php thing

 2012/3/22, Michael Save savetheinter...@omegasdg.com:
  Very nice!
 
  I'll have a proper look at this in the morning, and I'll try it out
  for myself. Looking forward to seeing more development on this.
 
  Michael
 
  On Thu, Mar 22, 2012 at 11:40 AM, Joseph Moniz joseph.mo...@gmail.com
  wrote:
  Hey,
 
  So i had my first Hackathon at work last week and my project was to
  prototype making a node.js clone using PHP instead of V8. So i
  snatched up libuv and joyent's HTTP parser and set off on a 24 hour
  coding spree to get something workable. By the time the sun was coming
  out the next morning the following code was working.
 
     ?php
 
     $http = new node_http();
 
     $http-listen(8080, function($request, $response) {
         $response-end(yay, super awesome response);
     });
 
     nodephp_run();
 
     ?
 
  The C code that powers it was whipped together really fast and is kind
  of hackish as a result. The code has some memory leaks that i haven't
  had time to fully track down yet. Some small portions of the code were
  borrowed from the phode project.
 
  In a naive benchmark on this simple server VS an equally simple server
  in node.js this implementation already out performs node.js in
  throughput by being able to serve just under 200% the amount of
  requests per second that node.js could. Take that with a grain of salt
  though because node.js has much more feature and is much more hardend
  from production use. I do believe the PHP binary will have some major
  performance gains over V8 as crossing the PHP -- C barrier seems to
  be a much lighter operation then crossing the V8 -- C++ barrier.
 
  Any help or feedback will be greatly appreciated. The projects source
  code can be found here: https://github.com/JosephMoniz/node.php
 
  - Joseph Moniz
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Node.PHP

2012-03-22 Thread Michael Save
Very nice!

I'll have a proper look at this in the morning, and I'll try it out
for myself. Looking forward to seeing more development on this.

Michael

On Thu, Mar 22, 2012 at 11:40 AM, Joseph Moniz joseph.mo...@gmail.com wrote:
 Hey,

 So i had my first Hackathon at work last week and my project was to
 prototype making a node.js clone using PHP instead of V8. So i
 snatched up libuv and joyent's HTTP parser and set off on a 24 hour
 coding spree to get something workable. By the time the sun was coming
 out the next morning the following code was working.

    ?php

    $http = new node_http();

    $http-listen(8080, function($request, $response) {
        $response-end(yay, super awesome response);
    });

    nodephp_run();

    ?

 The C code that powers it was whipped together really fast and is kind
 of hackish as a result. The code has some memory leaks that i haven't
 had time to fully track down yet. Some small portions of the code were
 borrowed from the phode project.

 In a naive benchmark on this simple server VS an equally simple server
 in node.js this implementation already out performs node.js in
 throughput by being able to serve just under 200% the amount of
 requests per second that node.js could. Take that with a grain of salt
 though because node.js has much more feature and is much more hardend
 from production use. I do believe the PHP binary will have some major
 performance gains over V8 as crossing the PHP -- C barrier seems to
 be a much lighter operation then crossing the V8 -- C++ barrier.

 Any help or feedback will be greatly appreciated. The projects source
 code can be found here: https://github.com/JosephMoniz/node.php

 - Joseph Moniz

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php