Re: Some more plane hacking...
| From: | Rasmus Lerdorf | Date: | Thu, 16 Aug 2001 17:42:33 +0000 |
| Subject: | Re: Some more plane hacking... | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-1575@lists.php.net to get a copy of this message | ||
> - The work needed to build a valid C extension in the terms of bug
> haunting, cross platform, PHP/Zend internals knowledge, speed of coding,
> etc is too big.
> - The number of contributors will be reduced draticaly. Don't know
> what's the general C knowledge here, but I know that mines for example
> is not valid for a seriuos work.
> - Moving PHP PEAR classes from one server to another is a trivial work,
> C classes shouldn't.
> - Most of PHP users haven't enought tools and knowledge to compile a
> external C extensions.
Yes, I thought there would be some anti-C sentiment like this here, which
is basically why I sent the probe out just to see how much there was.
That doesn't change the fact that PHP is not just for users that host
their pages with ISPs. It is also for people who build large sites on
servers they have full control over.
Have a look at the numbers. Take this example class:
::Smarty.test::
<?php
define("SMARTY_PHP_PASSTHRU",0);
define("SMARTY_PHP_QUOTE",1);
define("SMARTY_PHP_REMOVE",2);
define("SMARTY_PHP_ALLOW",3);
class Smarty
{
var $template_dir = './templates';
var $compile_dir = './templates_c';
var $config_dir = './configs';
var $debugging = false;
var $debug_tpl = 'file:debug.tpl';
var $debugging_ctrl = 'NONE';
var $global_assign = array( 'HTTP_SERVER_VARS' => array('SCRIPT_NAME')
);
var $compile_check = true;
var $force_compile = false;
var $caching = false;
var $cache_dir = './cache';
var $cache_lifetime = 3600;
var $insert_tag_check = true;
var $tpl_file_ext = '.tpl';
var $security = false;
var $left_delimiter = '{';
var $right_delimiter = '}';
var $show_info_header = false;
var $show_info_include = false;
}
?>
Obviously this class doesn't do much of anything at all. Running this
script:
<?php
require 'Smarty.test';
$x = new Smarty;
echo $x->config_dir;
?>
I get about 315 requests per second out of it on my laptop. Changing this
to simply be:
<?php
$x = new smarty;
echo $x->config_dir;
?>
(for the curious, eliminating the require call and putting the class
definition into the same file takes it from 315 to around 335)
Where smarty is an internal class written in C that initializes exactly
the same properties and constants and gives you the added ability to
specify these properties in your php.ini or even your httpd.conf file
gives me about 410 requests per second.
For something that is as intrinsic to a large site as a templating system,
a 25% speed increase just on property initialization is significant. And
this is before any of the methods have been converted which is where the
real performance benefit is likely to be seen.
The added benefits in an ISP situation is also obvious. In this case
Smarty configuration settings could be set on a per-virtualhost basis and
the astute ISP could sell this as a service.
> Let's define "professional". I have one server with 1,5 millon _hits_ a
> day with php, templates, postgres, and it's running fast and smooth. The
> amount of speed you can gain optimizing classes is nothing compared to
> optimizing queries, databse, SO, web server.
> If we are talking of > 50.000 visitors a day you're not talking in
> "general purpose" terms (isn't PEAR a "general purpose repository"?).
I would certainly hope that anything written using a lot of PEAR
components could handle much more than 50.000 visitors per day. That's
less than 1 request per second. Whenever I am building something I try to
make sure I go no lower than 50 requests/sec on the main pages of the
site. And my low watermark for a complete rethink/rewrite is at around 12
requests/sec. 12 request/sec translates to about 1 million hits per day.
> Just ask a question if you let me: the guys who are promoting C
> extension will join to pear and work in the this C extensions? will
> maintain them? will ensure cross-platform/cross-compiler ability? will
> attend bug reports?
There is no guarantee of that, just like there is no guarantee for that in
userspace-PEAR stuff. The C API hides most of the cross-platform issues,
just like the PHP scripting language itself does. But there will still be
issues, both in script-space and in C-space that could affect things
across different platforms.
-Rasmus