php-general Digest 3 Apr 2012 19:16:36 -0000 Issue 7759

Topics (messages 317436 through 317437):

Re: learning resources for PHP
        317436 by: Daniel Brown

Re: Node.PHP
        317437 by: Joseph Moniz

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
On Mon, Apr 2, 2012 at 23:53, Tim Dunphy <bluethu...@gmail.com> wrote:
> Hello list,
>
>  I am quite sure that you've heard this question at least a few times
> before. :) But I have been dabbling a bit in PHP for years and I've
> decided that its' high time that became serious about getting a solid
> grounding in it. Currently I work as a Sysadmin and have modest but
> reliable skills in bash and perl. But I consider PHP more of an
> artform and I really need to 'pick up a brush and start painting' so
> to speak.
>
>  So what I was wondering what websites, and books you'd recommend to
> someone who (for all intents and purpose) is just starting out.
>
>  On my hit list of things to learn are basic php / database
> interaction (mysql mainly).. then how to accelerate php interraction
> through memcache.. and eventually one I have all that down onto using
> some of the NoSQLs (mongo/cassandra/membase, etc).
>
> Thanks!
>
> -tim
>
>
> --
> GPG me!!
>
> gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B

    Your question is better asked (and will certainly be better
answered) on the general list at php-gene...@lists.php.net, Tim, and
I've CC'd the list for you.  If you haven't already, please subscribe
to that list to ensure you receive all the responses.

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

--- End Message ---
--- Begin Message ---
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/

--- End Message ---

Reply via email to