Re: [PHP-DEV] Server-Wide Persistent objects in PHP?

2001-12-05 Thread Yermo M. Lamers


Stig,

Actually, I've crawled through the Zend source, taken a look at all the
startup/shutdown routines, mapped everything out and it doesn't too bad at
all. I've started writing code and so far so good. If everything goes well
I should be announcing a solution sometime in January.

I had considered modifying Zend to add a global scope directly to the
language but because of the way they have things set up I'd have to modify
all the modules as well ... too much work right now. This is a classic
example of why using global externals is a very bad idea and Zend uses
them all over the place.

I agree that running a remote server to handle persistence is a much
easier way to go but it's not really something I want to do. If I can't
get this to work I'll give that a try.

-- Yermo

On Wed, 5 Dec 2001, Stig S. Bakken wrote:

 Importing objects into the current Zend/PHP instance and then updating
 them at request shutdown introduces a lot of tricky synchronization
 problems, I think it's very difficult to implement reliably with Zend as
 well.
 
 IMHO a better solution would be using a remote object access mechanism. 
 There are several choices available today, such as Corba, SOAP or
 XML-RPC (check out php4/pear/PEAR/Remote.php for an example
 implementation using XML-RPC).  According to Derick, SRM can do this
 today, which would probably be a lot faster than both Corba and the
 XML-based protocols.
 
  - Stig
 
 Yermo M. Lamers wrote:
  
  I took a look at Zend Accelerator/Cache. That's not really what I'm
  looking for.
  
  It's basically just a pseudo-compiler that caches compiled versions of
  pages. It's not really a live object cache.
  
  What I'm looking to do is to create a global scope where I can keep live
  pre-built instances of objects around. I agree the accelerator would
  improve the performance, but in my case it wouldn't improve it enough.
  
  I think I can probably get an order of magnitude performance improvement
  by pre-caching live objects and making them available to all pages in an
  application ... very much like mod_perl does.
  
  With the pseudo-compiler you get an improvement, but you're still building
  all your objects on every page, using them and destroying them .. you're
  just avoiding the load/compilation step. I want to avoid the
  load/compilation and instantiation steps because in my case, and for any
  really involved system, insantiation is going to be expensive.
  
  It looks like it should be doable if I can copy symbol tables in and out
  of the zend interpreter, but it's not clear to me what portions get tied
  inextricably to a given zend interpreter instance.
  
  -- Yermo
  
  On Mon, 26 Nov 2001, Andrei Zmievski wrote:
  
   On Mon, 26 Nov 2001, Andrei Zmievski wrote:
Yeah, it's already built and it's called Zend Encoder.
  
   Sorry, Zend Cache or Zend Accelerator, not sure what the current name
   is.
  
   -Andrei
  
  
   Freedom comes when you learn to let go.
Creation comes when you learn to say no.
 -madonna
  
  
  -
  DTLink Software   [EMAIL PROTECTED]
  Software Development and Consulting
  -
  
  --
  PHP Development Mailing List http://www.php.net/
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  To contact the list administrators, e-mail: [EMAIL PROTECTED]
 

-
DTLink Software   [EMAIL PROTECTED]
Software Development and Consulting
-


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] Server-Wide Persistent objects in PHP?

2001-11-26 Thread Yermo M. Lamers


Serializing to a file for a large number of objects isn't the correct
solution. For smaller projects it might be.

The ideal (e.g. correct) solution is to have a server global scope which
never disappears. Something like a $SERVER_GLOBALS[] array or some such.

For instance, it would be extremely cool to pre-load class files when the
server loads so you don't have to incur that overhead. It would be
extremely cool to instantiate objects at server start time and just have
them available ... basically making PHP have some mod_perl's capabilities.

I had looked at serializing, but if I understand correctly before you can
unserialize them back you have to load all the class files again ... which
in my case means 1000's of lines of code each time ... 

in my situation I'm running a system that has to load, compile and run
4-5 thousand lines of code  and that's just to /construct/ the
objects. I'd like to do that once at server load time and then not again.

-- Yermo


On Mon, 26 Nov 2001, Benjamin Barringer wrote:

 Why don't you use serialize and unserialize and write the objects to a file.
 Makes a tremendous performance improvement (for my particular code base). I
 realize this isn't exactly what you need but; it may be a suitable
 alternative?  You should also try out the Zend Cache. For a lot of my
 projects the cache is to $$$.
 
 Thanks
 Ben
 
 
 - Original Message -
 From: Yermo M. Lamers [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Sunday, November 25, 2001 7:50 PM
 Subject: [PHP-DEV] Server-Wide Persistent objects in PHP?
 
 
 
  I'm building a reusable component object system in PHP where construction
  of object trees, which needs to occur on every page, is very expensive.
 
  Running the subsequently built objects is very inexpensive.
 
  To make this system viable to use on high volume websites, I want to get
  rid of the construction of objects on every page part which means I
  want the ability to make object instances long lived. (i.e. build the
  object once and have it live for as long as the server lives similar to
  the way you can make objects server-wide global in mod_perl).
 
  Based on feedback I've gotten from the php-general list it looks like
  this kind of thing hasn't been implemented yet for PHP. Correct?
 
  If not, could anyone provide pointers where I could start taking a look at
  PHP internals to develop such a beast?
 
 Where I can find out:
 
  how are classes represented internally?
  how are objects represented?
 
  how can I establish classes/functions/variables/objects that have
  a server-wide global scope? What infrastructure needs to be kept
  around in order to keep these objects valid?
 
  can one have php interpreter instances share data? (i.e. might
  the best solution be to build another php interpreter instance
  that persists and have an interface to pass references in and
  out of it?)
 
  Any other suggestions would be greatly appreciated. From what I've been
  able to gather having a long-lived object cache in the serverr would
  make PHP much more viable for high load situations.
 
  On a related question, is there a way to pre-load class definitions when
  the server starts so that class definition files don't have to be
  re-parsed on a page by page basis?
 
  thanks,
 
  -- Yermo
 
  -
  DTLink Software   [EMAIL PROTECTED]
  Software Development and Consultinghttp://services.dtlink.com
  -
 
 
 
  --
  PHP Development Mailing List http://www.php.net/
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  To contact the list administrators, e-mail: [EMAIL PROTECTED]
 

-
DTLink Software   [EMAIL PROTECTED]
Software Development and Consulting
-


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] Server-Wide Persistent objects in PHP?

2001-11-26 Thread Yermo M. Lamers


Question for you, when you serialize to a file do the class definitions
get serialized along with it or do you have to pre-load your classes
before you can unserialize? (that seems to be the way it works but I may
be mistaken).

-- Yermo


On Mon, 26 Nov 2001, Andrey Hristov wrote:

 AFAIK PHP4 is better than PHP3 in that it makes some level of compilation.
 You may be serialize - de~ in files. If you use *nix you can choose to work with
 SysV semaphores and SysVShm (shared memory). Everything is in memory from one to 
another script invocation.
 So far I've seen only one script(system) which uses this capabilities of PHP. It's 
name is Oasis (oasis.sourceforge.net).
 In my tests its 3x-4x faster than analogous systems.
 For session data configure in your php.ini to use 'mm' instead of file for data 
storage.
 
 Best regards,
 Andrey Hristov
 IcyGEN Corporation
 http://www.icygen.com
 BALANCED SOLUTIONS
 
 
 - Original Message - 
 From: Yermo M. Lamers [EMAIL PROTECTED]
 To: Benjamin Barringer [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 Sent: Monday, November 26, 2001 7:03 PM
 Subject: Re: [PHP-DEV] Server-Wide Persistent objects in PHP?
 
 
  
  Serializing to a file for a large number of objects isn't the correct
  solution. For smaller projects it might be.
  
  The ideal (e.g. correct) solution is to have a server global scope which
  never disappears. Something like a $SERVER_GLOBALS[] array or some such.
  
  For instance, it would be extremely cool to pre-load class files when the
  server loads so you don't have to incur that overhead. It would be
  extremely cool to instantiate objects at server start time and just have
  them available ... basically making PHP have some mod_perl's capabilities.
  
  I had looked at serializing, but if I understand correctly before you can
  unserialize them back you have to load all the class files again ... which
  in my case means 1000's of lines of code each time ... 
  
  in my situation I'm running a system that has to load, compile and run
  4-5 thousand lines of code  and that's just to /construct/ the
  objects. I'd like to do that once at server load time and then not again.
  
  -- Yermo
  
  
  On Mon, 26 Nov 2001, Benjamin Barringer wrote:
  
   Why don't you use serialize and unserialize and write the objects to a file.
   Makes a tremendous performance improvement (for my particular code base). I
   realize this isn't exactly what you need but; it may be a suitable
   alternative?  You should also try out the Zend Cache. For a lot of my
   projects the cache is to $$$.
   
   Thanks
   Ben
   
   
   - Original Message -
   From: Yermo M. Lamers [EMAIL PROTECTED]
   To: [EMAIL PROTECTED]
   Sent: Sunday, November 25, 2001 7:50 PM
   Subject: [PHP-DEV] Server-Wide Persistent objects in PHP?
   
   
   
I'm building a reusable component object system in PHP where construction
of object trees, which needs to occur on every page, is very expensive.
   
Running the subsequently built objects is very inexpensive.
   
To make this system viable to use on high volume websites, I want to get
rid of the construction of objects on every page part which means I
want the ability to make object instances long lived. (i.e. build the
object once and have it live for as long as the server lives similar to
the way you can make objects server-wide global in mod_perl).
   
Based on feedback I've gotten from the php-general list it looks like
this kind of thing hasn't been implemented yet for PHP. Correct?
   
If not, could anyone provide pointers where I could start taking a look at
PHP internals to develop such a beast?
   
   Where I can find out:
   
how are classes represented internally?
how are objects represented?
   
how can I establish classes/functions/variables/objects that have
a server-wide global scope? What infrastructure needs to be kept
around in order to keep these objects valid?
   
can one have php interpreter instances share data? (i.e. might
the best solution be to build another php interpreter instance
that persists and have an interface to pass references in and
out of it?)
   
Any other suggestions would be greatly appreciated. From what I've been
able to gather having a long-lived object cache in the serverr would
make PHP much more viable for high load situations.
   
On a related question, is there a way to pre-load class definitions when
the server starts so that class definition files don't have to be
re-parsed on a page by page basis?
   
thanks,
   
-- Yermo
   
-
DTLink Software   [EMAIL PROTECTED]
Software Development and Consultinghttp://services.dtlink.com
-
   
   
   
--
PHP Development

Re: [PHP-DEV] Server-Wide Persistent objects in PHP?

2001-11-26 Thread Yermo M. Lamers


Markus,

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).

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?

thanks,

-- Yermo

On Mon, 26 Nov 2001, Markus Fischer wrote:

 On Mon, Nov 26, 2001 at 12:18:23PM -0500, Yermo M. Lamers wrote : 
  Question for you, when you serialize to a file do the class definitions
  get serialized along with it or do you have to pre-load your classes
  before you can unserialize? (that seems to be the way it works but I may
  be mistaken).
 
 Class definition is not safed.
 
 - Markus
 

-
DTLink Software   [EMAIL PROTECTED]
Software Development and Consulting
-


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] Server-Wide Persistent objects in PHP?

2001-11-26 Thread Yermo M. Lamers


I took a look at Zend Accelerator/Cache. That's not really what I'm
looking for.

It's basically just a pseudo-compiler that caches compiled versions of
pages. It's not really a live object cache. 

What I'm looking to do is to create a global scope where I can keep live
pre-built instances of objects around. I agree the accelerator would
improve the performance, but in my case it wouldn't improve it enough.

I think I can probably get an order of magnitude performance improvement
by pre-caching live objects and making them available to all pages in an
application ... very much like mod_perl does. 

With the pseudo-compiler you get an improvement, but you're still building
all your objects on every page, using them and destroying them .. you're
just avoiding the load/compilation step. I want to avoid the
load/compilation and instantiation steps because in my case, and for any
really involved system, insantiation is going to be expensive.

It looks like it should be doable if I can copy symbol tables in and out
of the zend interpreter, but it's not clear to me what portions get tied
inextricably to a given zend interpreter instance.

-- Yermo


On Mon, 26 Nov 2001, Andrei Zmievski wrote:

 On Mon, 26 Nov 2001, Andrei Zmievski wrote:
  Yeah, it's already built and it's called Zend Encoder.
 
 Sorry, Zend Cache or Zend Accelerator, not sure what the current name
 is.
 
 -Andrei
 
 
 Freedom comes when you learn to let go.
  Creation comes when you learn to say no.
   -madonna 
 

-
DTLink Software   [EMAIL PROTECTED]
Software Development and Consulting
-


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DEV] Server-Wide Persistent objects in PHP?

2001-11-25 Thread Yermo M. Lamers


I'm building a reusable component object system in PHP where construction
of object trees, which needs to occur on every page, is very expensive. 

Running the subsequently built objects is very inexpensive. 

To make this system viable to use on high volume websites, I want to get
rid of the construction of objects on every page part which means I 
want the ability to make object instances long lived. (i.e. build the
object once and have it live for as long as the server lives similar to
the way you can make objects server-wide global in mod_perl).

Based on feedback I've gotten from the php-general list it looks like
this kind of thing hasn't been implemented yet for PHP. Correct?

If not, could anyone provide pointers where I could start taking a look at
PHP internals to develop such a beast? 

   Where I can find out:

how are classes represented internally?
how are objects represented?

how can I establish classes/functions/variables/objects that have
a server-wide global scope? What infrastructure needs to be kept
around in order to keep these objects valid?

can one have php interpreter instances share data? (i.e. might
the best solution be to build another php interpreter instance
that persists and have an interface to pass references in and
out of it?)

Any other suggestions would be greatly appreciated. From what I've been
able to gather having a long-lived object cache in the serverr would
make PHP much more viable for high load situations.

On a related question, is there a way to pre-load class definitions when
the server starts so that class definition files don't have to be
re-parsed on a page by page basis?

thanks,

-- Yermo
 
-
DTLink Software   [EMAIL PROTECTED]
Software Development and Consultinghttp://services.dtlink.com
-



-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DEV] Module writing question: Sharing Resources between separate modules.

2001-06-18 Thread Yermo M. Lamers


I would like to write a PHP module that makes use of an already
established Mysql connection.

To make things clean, I'd like the exported functions from my new module
to accept MySQL-Link resources as in:

$mysql_conn = mysql_connect(  );

my_custom_module_func( $mysql_conn );

From my reading of ext/mysql/php_mysql.c it looks like you need to have
access to the return code from zend_register_list_destructors_ex() in
order to be able to lookup the resource passed to you using
ZEND_FETCH_RESOURCE2().

In ext/mysql/php_mysql.c le_link and le_plink are declared static and
there's no clean way of getting at them to get the resources.

What am I missing? 

How can can I get at the MYSQL * connection set up by the mysql module
from within my module?

Any pointers to sample code or information would be greatly appreciated,

thanks,

-- Yermo 

-
   Try Personal Stock Monitor for Windows(tm) for FREE at:
 http://www.personalstockmonitor.com
   Powerful Desktop Software for Online Investors
-


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]