
Refactored PHP engine makes Wordpress 20% faster - mrsaint
http://news.php.net/php.internals/73888
======
neals
I love how, through all the hate and bandwagoning, some people don't get
discouraged and actually do something to improve the product.

We still do new projects in PHP and we couldn't be happier.

~~~
adamors
> We still do new projects in PHP and we couldn't be happier.

I concur, especially when frameworks like Symfony exist. Reading all this
smack talk about PHP on HN is so alien considering how thriving the PHP
community actually is.

~~~
awestroke
Nobody mentions how much or little the PHP community thrives. People point out
how bad PHP compares against other languages. The fact that you enjoy using
PHP and that you can create great products with it does not imply that it has
no flaws.

Many have been where you are now, and then moved on to other languages to
never ever look back. From what I've seen, the reverse is much less common.

~~~
adamors
> Nobody mentions how much or little the PHP community thrives. People point
> out how bad PHP compares against other languages.

I don't actually think that faults in a language matter that much if the
people using it are competent. Both Javascript and Perl come close to PHP in
terms of negative traits, yet a lot of good software was written with both.
The same can be said about PHP, the only difference is that people on HN have
very little idea about what contemporary PHP (language and software) looks
like.

~~~
meowface
There are many good PHP web frameworks out there today, yes. These don't
somehow erase PHP's core flaws as a language though.

You can make a new project in Symfony or Laravel, sure, but you'll get that
same niceness plus way more goodies if you use a popular Python or Ruby
framework.

~~~
debaserab2
I think you need to qualify that a bit - what are "way more goodies" exactly?

Can you name something that Python can do that PHP can't?

~~~
camus2
Real production ready servers ,complex scientific calculations, 2d, 3d games ,
to name a few things. PHP is not general purpose. Python is.

PHP has type hinting and interfaces that makes it "java" like(it's a
strength).

Python doesnt have interfaces but allows type hinting through decorators.

    
    
        @typecheck
        def gimmeFloat(a:int, b:list, c:tuple=(1,2,3)) -> float:
            return 3.14

~~~
jbeja
And who is talking here about a general purpose lenguage in this context, i
only care about the web stuff i don't need things that ain't gonna use.

~~~
ulisesrmzroche
It's also a far more readable language, which matters more than anything in
large-scale projects

On the other hand, <? ?>.

~~~
jbeja
Large scale projects doesn't need "more redeable" languages, it needs good
engeneering and type checks.

------
lucb1e
> Wordpress 3.6 – 20.0% gain (253 vs 211 req/sec)

How do you generate 211 pages per second on Wordpress to begin with? My server
does page generation for my own custom-built blog in ~15ms, but takes a
whopping three seconds for a single Wordpress page. I know it's somewhat
offtopic and it's about the relative results, but what hardware is this?

~~~
dangrossman
My Linode VPS spits out WordPress pages in 33.811ms (via ApacheBench,
concurrency=10 for a couple hundred requests). I don't use any kind of
content/page cache. There's no reason WordPress would be 200 times slower than
your custom blog -- WordPress isn't some kind of complex software. It's a
handful of very small PHP classes that choose a theme file based on the URL,
include it, run a database query to select some posts, wrap the result rows in
objects, and pass them to the theme to spit out. I've had hundreds of
concurrent visitors on my blog without registering any load. If your site is
taking 3 seconds to return a page, there's something wrong and it's not the
choice of blog platform.

~~~
lucb1e
I meant a clean wordpress install. No themes, no plugins, just a basic
install. Three seconds. My own blog does about 3 mysql queries and manages
that in 8ms at best (usually 22ms at worst; typical seems to be around 15ms).
The most limiting factor for Wordpress was cpu speed.

~~~
bhousel
Maybe try increasing the PHP memory limit? I don't think Wordpress is causing
the slowness you are seeing.

~~~
will_work4tears
Yeah, WordPress can get slow pretty quick, but a naked install should be
pretty snappy. The codebase itself is pretty small (~50kLOC) but the DB
queries can get ugly depending on the plugins installed. Naked WP on GoDaddy
or similary crap shared hosting site can be slow, but certainly not on a VPS.

~~~
lucb1e
Mostly CPU usage would jump to 100%, it's not mysql or RAM shortage. I know an
Intel atom isn't much, but it ought to do better than this, especially
compared to custom software.

------
ohwp
Refactoring Wordpress will make it even faster. Look at the difference between
Drupal and Wordpress. It's amazing Wordpress is still used for big sites while
a ton of recourses could be saved.

But great work on the PHP engine!

~~~
nacs
Agreed. I ran a benchmark against CodeIgniter on a test box recently and was
suprised that a single query app performance went from around ~20k req/s with
raw PHP (no framework) to around ~3k req/s with CI and thought that was bad
for a framework. I didn't realize Wordpress performance was so much worse
especially given its popularity.

Most Wordpress sites use a caching plugin like WP Super Cache or Varnish-type
setup if they get decent traffic though.

~~~
jafaku
CI is a badly designed and outdated framework. For real speed you should use
something more professional like Symfony2.

~~~
mtbcoder
I won't disagree with you that CI is outdated, but it was originally created
to work around the limitations of PHP4 and early versions of 5.x. Looking back
in hindsight, it may seem "badly designed", but that would be taking it out of
context.

Also, CI out performs Symfony in the web framework benchmarks:
[http://www.techempower.com/benchmarks/](http://www.techempower.com/benchmarks/).
I certainly would never equate Symfony to "real speed".

~~~
jafaku
You really think those guys know how to configure for production a hundred
frameworks? If you base your decisions on those benchmarks, you are gonna have
a bad time.

~~~
mtbcoder
I'm sure their benchmarks are more than adequate. In either case, if your
barometer for what makes a good PHP framework is based on performance, you
certainly wouldn't be choosing Symfony. If anything you'd go for for HHVM or
Phalcon.

~~~
jafaku
That makes no sense whatsoever. Symfony2 is fast as hell. If you don't think
so, you simply don't know how to properly configure it for production. There
isn't much _real_ speed you can gain from using weird things like Phalcon,
unless you don't know the first thing about caching. In fact, not having all
the caching mechanisms that Symfony2 gives you will probably _slow down_ your
application, even if your code is written in C.

~~~
nacs
You realize that those benchmarks are all open source and they encourage
patches from anyone if they can demonstrate it benches better?

So instead of just saying their Symfony benchmarks are bad, submit a pull
request to fix whatever you think is wrong so they can get more accurate
benchmarks next time.

Also their tests are run without caching for a reason. It's not a test of the
language/framework if they just use whatever language to generate a
static/cached file and serve it with nginx.

~~~
jafaku
Really? I'm supposed to go and work for free for them, just to prove your
wrong? No thanks.

> Also their tests are run without caching for a reason. It's not a test of
> the language/framework if they just use whatever language to generate a
> static/cached file and serve it with nginx.

Haha lol, so the tests are explicitly meaningless. I guess I'm done here then.

------
frik
Great news. HHVM and now PHP 5.7, both with JIT - the future of PHP looks
bright.

~~~
dparoski
To my knowledge a JIT compiler is not being added to PHP 5.7. Can you clarify
your comment or provide a link to the source where you heard this?

~~~
captain_mars
I'm not the person you replied to, but I got the same impression.

The linked email in turn links to the PHP NG page
([https://wiki.php.net/phpng](https://wiki.php.net/phpng)) on which the
version number mentioned is 5.7.0-dev

------
trebor
Good news, any idea which version this will be included in? I know PHP 5.6 is
already in beta, so I'd assume this'll be PHP 5.7, but this is really good
news. We have some sites that are just begging for an actual 10-30% increase
in speed.

~~~
LawnGnome
I suspect this'll be the basis of a new major version, based on early
discussions. It probably won't be a 5.x release.

~~~
frik
There are already PHP 6 books out there from 2009 (planned v6 renamed to 5.3):
[https://www.google.com/search?q=php+6&tbm=bks](https://www.google.com/search?q=php+6&tbm=bks)

They could name it PHP 7 to avoid further confusion.

~~~
velodrome
PHP 6 was really about unicode support. It will actually create even confusion
among veterans. Also, those PHP 6 books are really aimed at beginners.

In addition, skipping a version number also creates confusion. If they were
going to go this route, they should have done it a long time ago (around
2010-2011).

[http://www.slideshare.net/andreizm/the-good-the-bad-and-
the-...](http://www.slideshare.net/andreizm/the-good-the-bad-and-the-ugly-
what-happened-to-unicode-and-php-6)

------
devNoise
This sounds like a nice improvement to PHP performance. Are there any parts of
the language that will have to change for this enhancement? I expect that that
changes will be minimal, if any are needed.

~~~
rossriley
From what I can see there shouldn't be any userland breaks unless it's very
obscure.

In the internals all of the zend_hash apis have been updated so it may have an
effect on some extensions, though the core extensions can all be updated.

~~~
devNoise
I think you're right. The line that made me think that something might change
is:

"we changed the basement trying to keep most of the building unchanged."

The "most" part made me wonder what obscure part of userland it would be.

------
nodesocket
Love the work, but honestly by the time PHP 5.7 is ready for mainstream (with
extension support mysqli, memcache, mongo), Facebook HHVM will be the defacto
standard. FB has a huge head start and can throw nearly unlimited money and
engineering hours at the problem. Seems like a losing battle, but perhaps I am
wrong.

~~~
NameNickHN
PHP's success is the result of PHP being available at even the tiniest
webhost. I don't see that happen for FaceBook HHVM, though. FaceBook HHVM
performance results will spur on Zend's efforts in making the PHP engine
faster, though.

------
munimkazia
It is good to hear that they even managed to refactor their code, even if you
don't look at the performance benefits. Now, I hope that their next major
upgrade will be a complete API overhaul, though it means making the existing
thousands of themes and plugins incompatible.

------
fastest963
Can't wait to play around with this once they support a few more extensions!

------
nijiko
The parser needs to be rewritten really.

~~~
nly
Why do you say that? The parser looks no more or less horrible than the rest
of the code base.

------
woah
Why does it matter? Visitors should never hit WP anyway if you are smart. Set
up caching.

~~~
andy_adams
It makes a big difference if your site isn't just for displaying static HTML
content - for example, a WordPress-powered community where users log in to
your site.

