Re: Server-Wide Persistent objects in PHP?
| From: | Shane Wright | Date: | Mon, 26 Nov 2001 17:30:13 +0000 |
| Subject: | Re: Server-Wide Persistent objects in PHP? | ||
| References: | 1 2 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-71692@lists.php.net to get a copy of this message | ||
Hi Thread!
On Monday 26 Nov 2001 5:03 pm, James Moore wrote:
> > Yea, that's the problem. In my application, just loading the class files
> > on each page adds quite a bit of overhead. (1000's of lines of code).
> Only load what you need then :) Or rewrite in C.
I'm having similar issues - and coming up with the same two solutions,
however....
- only load what you need.
Yup, conditional includes rock! But, keeping track of which bits each page
needs is a pain; and when things are integrated, most things tend to need at
least something from most other things - so without a fine-grained approach
there is little gain, and with a fine-grained approach there's lots of
overhead...
- rewrite in C.
My other solution too - write language extensions in C and compile them into
PHP. Not an ideal solution IMO (why are we using PHP anyway....). This
involves lots of effort and another language on top of the 4 already used in
most projects this size (PHP, SQL, HTML, Javascript...).
Some sort of persistence is definately required - I like that we can extend
the language but I dont feel it should be necessary purely for performance...
Just my 2c...
--
Shane
> > I've taken a look through the PHP/Zend source and it looks to me like it
> > would be possible to create a module built around a modified version of
> > php_execute_script() that:
> >
> > 1. loads, compiles and executes a script.
> >
> > 2. saves the state of the global tables Zend uses to
> > manage class definitions, objects, functions, variables, etc
> > (since there are so many globals used in Zend it doesn't look
> > like you can instantiate a second instance of the PHP interpreter
> > inside a single process, correct?)
> >
> > 3. exports some function calls to PHP that would allow object
> > instances (and their corresponding class definitions) to be imported into
> > the local name space.
> >
> > Ideally I'd set the module up so that all these classes and instantiation
> > happen in the php.ini file at server start time. Now wouldn't that be
> > cool?
> >
> > The question I have is what other hooks are there inside PHP that would
> > prevent this from working? Can I copy a pre-built symbol table (and class
> > definition table, etc) that I saved from a previous run of the PHP
> > interpreter (on a previous page) into a new one without having it crash?
>
> This is a very very complex process as there are a lot of dependencies
> through out the symbol table especially when dealing with classes. APC
> attempts this but doesnt do it brilliantly when classes are inherited etc.
> The Zend Cache is the only fully reliable type of system you are talking
> about I suggest you look at that.
>
> - James