Benchmarking 3 PHP Accelerators 81
jfbus writes "PHP, like all scripting languages, suffers from having to parse all script files each time a page is displayed. Accelerators (opcode caches) are necessary to speed PHP enough for large websites. Here is a benchmark of the major PHP accelerators (Zend platform, apc and eAccelerator)."
Forgive me for my stupidity, (Score:1)
How does a function defined inside a condition get changed into opcode? Does it place a copy of both functions everywhere where Example() is called?
Re:Forgive me for my stupidity, (Score:2, Informative)
Re:Forgive me for my stupidity, (Score:1)
Re:Forgive me for my stupidity, (Score:2)
When someone says they have a "can not redeclare class X" error, it's probably because of a caching program being added. It's kept a copy of the compiled script... but keeps hitting those pesky "include()" calls, and reloads what it previously included in the compiled version, or it fails to include the correct file, because it already finished reading its includes.
With some applications, though, the time to c
Re:Forgive me for my stupidity, (Score:2)
It's a substantial difference, with heavy php+database pages like forum indexes generating in 0.3 to 0.5 seconds vs. 2 - 3
Re:Forgive me for my stupidity, (Score:2)
Re:Forgive me for my stupidity, (Score:2)
Assuming the development on eAccelerator is on the right track, I'm sure I will be using it at some point down the road.
not really scientific (Score:1)
Re:not really scientific (Score:2)
Re:not really scientific (Score:2)
Re:not really scientific (Score:2)
Of course if your PHP site is seeing the sort of traffic levels that require an optimzer it's very likely you will in fact want the support that comes with Zend Platform - not to mention the integration and debugging features with Zend Studio. (I have no relationship with Zend other than being a happy customer).
Re:not really scientific (Score:2)
You see, you want an optimizer for quite another reason then the amount of traffic you get.
Simply put, it makes running the website less resource intensive, which means that you can host it at a lower cost. You can afford a lot more complexity with the same amount of resources, so you can offer more/better functionality, your web hosting will interfer less with other services on the same physical machine etc etc. Assumin
Three? (Score:1)
Like all scripting languages? (Score:4, Informative)
This isn't something common to all scripting languages. For example, when Python scripts are executed, they are compiled to byte-code, and the result is saved for faster execution next time. Of course, in typical web hosting situations, the web server doesn't have permission to write to the filesystem, but you can quickly and easily compile the bytecode yourself [incutio.com]. ASP.NET also compiles once only.
In fact, I believe it's an oddity of PHP that it needs add-ons in order to do this, and I think the next version of PHP will have fixed this. I don't know where they got the idea that all scripting languages must always parse the script on every invocation.
Re:Like all scripting languages? (Score:1)
Maybe that's because PHP isn't supposed to be used for writing daemons.
Re:Like all scripting languages? (Score:1)
Re:Like all scripting languages? (Score:2)
Only if your setup isn't smart enough to notice when the source has changed and there's no way of disabling the caching. It's an old problem sure, but one with plenty of solutions.
Re:Like all scripting languages? (Score:1)
Re:Like all scripting languages? (Score:2)
Yes, I use mod_python a fair bit. The reloading rules can be confusing if you aren't used to them, but once you understand them, it's easy to set up a sane development environment.
The trouble with the way PHP does things is that even when you cache opcodes, you are still executing everything for every request. Since the Python interpreter is persistent across multiple requests, the expensive operations only need to be e
Re:Like all scripting languages? (Score:1)
Re:Like all scripting languages? (Score:2)
Re:Like all scripting languages? (Score:3, Informative)
Python's loading algorithm goes something like this:
Never in my time developing Python have I once encountered a problem with stale compiled objects. If your language
Re:Like all scripting languages? (Score:2)
Re:Like all scripting languages? (Score:2)
Yes, and things like mod_perl just keep the Perl interpreter in memory, and load modules only once. I think all traditional "scripting" languages use something like that now, CGI is rather 1996...
Re:Like all scripting languages? (Score:3, Interesting)
That's one of Zend's main revenue sources. They developed PHP, they developed the accelerator. But they sell the accelerator and offer PHP free with sources as a lure.
What I'm saying is, no, it won't be fixed in the next version of PHP.
Re:Like all scripting languages? (Score:3, Insightful)
Rasmus Lerdorf has posted a PHP 6.0 wishlist [php.net] that includes an opcode cache. Rasmus is the founder of the PHP project.
Zend might sell an accelerator, but that doesn't mean they can simply forbid the founder of PHP from adding the feature to his own project. At this point, I think the question is which opcode cache gets added to PHP, not whether it will happen.
Re:Like all scripting languages? (Score:2)
Re:Like all scripting languages? (Score:2)
Some people have used that as part of the definition of "scripting language". Pre-dot-Net ASP* also worked that way, although I got out of that a long time before
There was a time when this idea had at least some value. However, it's been a while now since I've heard a useful definition of "scripting language" be
Re:Like all scripting languages? (Score:2)
Re:Like all scripting languages? (Score:2)
I think the definition that most closely mirrors what people consider to be scripting languages these days is that it's a scripting language if the compilation step is automatic, optional or non-existent.
PHP not copied from ASP (Score:2)
PHP was *not* copied from ASP. PHP was originally started in (late?) '94, and was growing in popularity by 1996, when MS introduced their HTC stuff. IIRC "ASP" wasn't in real use until some time in 1997, by which time PHP was widely used.
http://en.wikipedia.org/wiki/Active_Server_Pages [wikipedia.org] says ASP 1.0 was out in Dec 1996. IIRC Rasmus has mentioned that some Microsoft engineers were on an early PHP dev mailing list so
Re:Like all scripting languages? (Score:2)
It's not a True Scripting Language if there's a just-in-time compiler involved, now is it?
Re:Like all scripting languages? (Score:2)
Python doesn't come with a JIT compiler. The .pyc files it saves out are byte code, not machine instructions.
.pyc files simply keep Python from having to re-compile from source to byte code every time the module is loaded. It doesn't provide any performance advantage past that initial module import stage.
As an aside: the
That said, Pyco [sourceforge.net] can generate x86 instructions from Python code in a manner very much like a JIT
Re:Like all scripting languages? (Score:2)
Why wouldn't it be? JIT compilation is merely a rather advanced kind of interpreter. AFAIK Python already has one [sourceforge.net] (even though dev on it has more or less stopped) and PyPy [codespeak.net] will supposedly include one out of the box, and I think Matz would like Ruby2 to have a JIT compiler.
Re:Like all scripting languages? (Score:1)
From wikipedia [wikipedia.org]: Those languages which are suited to scripting are typically called scripting languages. Many languages for this purpose have common properties: they favor rapid development over efficiency of execution; they are often implemented with interpreters rather than compilers; and they are strong at communication with program components written in other languages.
* lon3st4r *
Turck MMCache (Score:3, Informative)
Re:Turck MMCache (Score:4, Informative)
Reincarnated here: http://eaccelerator.net/ [eaccelerator.net]
Re:Turck MMCache (Score:2)
Re:Turck MMCache (Score:2)
Ah, I see:
eAccelerator [sourceforge.net] was born in December 2004 as a fork of the Turck MMCache project. Turck MMCache was created by Dmitry Stogov and much of the eAccelerator code is still based on his work.
But it would've been nice to see a comparision between MMCache and eAccelerator as well.
Re:Turck MMCache (Score:1)
I'd have to agree with you on this one – I've never used eAccelerator, and in fact I've never even heard of it up until just now, but I happen to like MMcache a great deal. I know that Wikipedia uses MMcache [wikimedia.org], and I've been using it extensively on my own server [dyndns.org] as well, because it's a slow server and literally everything on there is generated by some PHP script or other...
Re:Turck MMCache (Score:2)
I still use it because it's rock solid reliable and the performance is still fantastic. I'm now tempted to try out eAccelerator, but my gut tells me that any performance improvements would be fairly small. Anyhow, I'm adding it to the bottom of my "stuff to try" list.
Re:Turck MMCache (Score:1)
They are. The big advantage of eAccelerator over Turck is its PHP5 support, rather than performance enhancements.
learn your perl pragmas: use strict; (Score:2)
sub fix_bad_words {
shift;
my $BADWORDREGEX = shift || "(fuck|shit|cunt)";
join map split $IFS, {/$BADWORDREGEX/ ? "*bleep*" : $_;}, $,;
}
Bonus points: So what does it do?
Parsing? (Score:1, Flamebait)
Speak for yourself, PHP weenie. My Perl code is parsed and "compiled" only when I restart the FastCGI handler(s) for my Catalyst [catalystframework.org] web app(s). My templates [tt2.org] are (I'm sure) parsed on each invocation though. The situation is probably similar for other real scripting languages e.g Python and Ruby.
Re:Parsing? (Score:2)
I'd be surprised. I know Apache::ASP compiles each web page ("template") down to a Perl subroutine once per execution (unless you change it); I'd bet the TT works the same way. The speed gains are too large to ignore, especially in a web environment, and Perl makes it too easy.
Re:Parsing? (Score:2)
My templates are (I'm sure) parsed on each invocation though.
Apache::Template with mod_perl will allow you to have Template-Toolkit preloaded.
Comparison against other languages (Score:2)
Re:"Accelerating" PHP is a waste of time (Score:2, Redundant)
The language helps though, the easiest example one can give is the dozen of different functions just to escape DB query parameters (there are at least 3 for mysql alone -- addslashes, mysql_escape_string and mysql_real_escape_string, only the latter being safe), or the wonderful built-in magic quotes that basically addslashes()
Re:"Accelerating" PHP is a waste of time (Score:3, Insightful)
The extension model may be a matter of taste. I'll giv
Re:"Accelerating" PHP is a waste of time (Score:1)
Wrong, PHP doesn't use Perl-like syntax, it uses what it things of as Perl-ish "$" prefixes, the point that these wonderful PHP devs missed is that prefixes actually have a meaning in Perl, in PHP they don't (yes I do know that they're data access shit(1), and I do also know that this is retarded). PHP also removed much of the
Re:"Accelerating" PHP is a waste of time (Score:1)
Have you even heard of "taint-mode" in Perl? It's a built security mode to make sure no user supplied data can ever make it's way into sensitive areas (system calls, filenames, etc) without have been "untainted" first. I'd say that's a pretty big difference in the security of the languages.
Re:"Accelerating" PHP is a waste of time (Score:1)
Re:"Accelerating" PHP is a waste of time (Score:1)
You say that VBScript is bad, but please note that the ASP object model is pretty nice, and that you can access it through any ActiveScript language. Windows comes by default with VBScript and JScript, but you can also use PerlScript [activestate.com], ActiveRuby [infoseek.co.jp], and Python (with the Win32 extensions [python.net]). That also means you get to use the libraries of those languages, which are a lot better than what VBScript itself has to offer.
Re:"Accelerating" PHP is a waste of time (Score:2)
Re:"Accelerating" PHP is a waste of time (Score:3, Informative)
function Redirect($location) {
header("Location: $location");
die;
}
function MapPath($file) {
return realpath($file);
}
Re:Farewell PHP/Zend (Score:1, Troll)
Woonderful, these tools reimplemented ECMAScript, fucked it up with ugly, $-prefixed builtins, dumbed it some more and then sprinkled their spec with illegible english. What an awesome language not to code in.
Re:Farewell PHP/Zend (Score:2)
Yeah, that's probably why the very first paragraphs of the front page tell me i can code in neko...
eAccelerator is great (Score:2)
Zend's tragedy core dumps apache every 20 minutes.
PHP5.1 + eAccelerator Re:eAccelerator is great (Score:2)
OH I see.. I'm using a version that works fine with PHP 5.1+. Fairly quick on this quad-550Mhz Dell.
The only stupid part is updating from PHP 5.1.2 required a recompile of eAccelerator.
Really necessary? (Score:2)
It's a modest machine. Dual 600mhz p3, 256mb of ram. How bad/good/busy do things have to get before a php accelerator becomes necessary?
Re:Really necessary? (Score:1)
xcache from lighttpd (Score:1)