dl and extension directive in php.ini

php.internals

Hans Zaunere

23 years ago
Hello, I'm hearing some conflicting reports and I'd like to see other's thoughts on this. Loading an external module using dl() at runtime obviously loads the module per request (ie, performance hit). On the other hand, which I believe is the recommended method anyway, is using the extension= directive in php.ini. While this is still a dynamic module load, it should only happen once; for instance when the Apache child process is forked. However, while reading some Zend API docs I began to doubt this, so I'm interested in some confirmations. Basiclly, I'm of the understanding that dl() is 'bad' anyway, so I guess the question really is: when specifying a dynamic module (.so) from php.ini, does it get loaded per request or at process creation time? Thanks, H

Derick Rethans

23 years ago
Hello Hans, On Thu, 1 May 2003, Hans Zaunere wrote:
> Basiclly, I'm of the understanding that dl() is 'bad' anyway, so I guess the > question really is: when specifying a dynamic module (.so) from php.ini, does > it get loaded per request or at process creation time?
Per process creation. Derick
-- "my other box is your windows PC" ------------------------------------------------------------------------- Derick Rethans http://derickrethans.nl/ PHP Magazine - PHP Magazine for Professionals http://php-mag.net/ -------------------------------------------------------------------------

Rasmus Lerdorf

23 years ago
> On the other hand, which I believe is the recommended method anyway, is using > the extension= directive in php.ini. While this is still a dynamic module > load, it should only happen once; for instance when the Apache child process > is forked. However, while reading some Zend API docs I began to doubt this, > so I'm interested in some confirmations.
Not sure what you are reading, but yes, if you use extension=foo.so in your php.ini file, then foo.so is only loaded at server startup time. However, due to funky Apache startup stuff, it is actually loaded, unloaded and then loaded again at startup, but from then on there is no per-request loading or unloading as there is with dl(). -Rasmus

Derick Rethans

23 years ago
On Thu, 1 May 2003, Rasmus Lerdorf wrote:
> Not sure what you are reading, but yes, if you use extension=foo.so in > your php.ini file, then foo.so is only loaded at server startup time. > However, due to funky Apache startup stuff, it is actually loaded, > unloaded and then loaded again at startup, but from then on there is no > per-request loading or unloading as there is with dl().
Just wondering... do you know the reason for that funky apache loading stuff? Derick
-- "my other box is your windows PC" ------------------------------------------------------------------------- Derick Rethans http://derickrethans.nl/ PHP Magazine - PHP Magazine for Professionals http://php-mag.net/ -------------------------------------------------------------------------

Rasmus Lerdorf

23 years ago
On Thu, 1 May 2003, Derick Rethans wrote:
> On Thu, 1 May 2003, Rasmus Lerdorf wrote: > > > Not sure what you are reading, but yes, if you use extension=foo.so in > > your php.ini file, then foo.so is only loaded at server startup time. > > However, due to funky Apache startup stuff, it is actually loaded, > > unloaded and then loaded again at startup, but from then on there is no > > per-request loading or unloading as there is with dl(). > > Just wondering... do you know the reason for that funky apache > loading stuff?
It's the two-pass config stuff to check the validity of the configuration. Supposedly anyway. I don't really see why it still does that. -Rasmus

Sascha Schumann

23 years ago
> > Just wondering... do you know the reason for that funky apache > > loading stuff? > > It's the two-pass config stuff to check the validity of the configuration. > Supposedly anyway. I don't really see why it still does that.
'Thanks' to that IRCG 4 has become hot-swap'able, i.e. you can upgrade the binary without interrupting the service. I probably would not have added that ability without Apache's awkward load and restart behaviour. - Sascha

Hans Zaunere

23 years ago
--- Derick Rethans <derick@php.net> wrote:
> On Thu, 1 May 2003, Rasmus Lerdorf wrote: > > > Not sure what you are reading, but yes, if you use extension=foo.so in > > your php.ini file, then foo.so is only loaded at server startup time. > > However, due to funky Apache startup stuff, it is actually loaded, > > unloaded and then loaded again at startup, but from then on there is no > > per-request loading or unloading as there is with dl().
pfweww, that's good then. I couldn't imagine why it would need to reload for every request, but after reading (or reading *too* deeply): http://us2.php.net/manual/en/zend.possibilities.php#zend.possibilities.external http://us2.php.net/manual/en/zend.possibilities.builtin.php I started to get worried. I guess, in the first link above, under Disadvantages, this statement caught me: "The shared objects need to be loaded every time a script is being executed (every hit), which is very slow." This isn't true, though. Anyway, thank you, H

Derick Rethans

23 years ago
On Thu, 1 May 2003, Hans Zaunere wrote:
> pfweww, that's good then. I couldn't imagine why it would need to reload for > every request, but after reading (or reading *too* deeply): > > http://us2.php.net/manual/en/zend.possibilities.php#zend.possibilities.external > http://us2.php.net/manual/en/zend.possibilities.builtin.php > > I started to get worried. I guess, in the first link above, under > Disadvantages, this statement caught me: > > "The shared objects need to be loaded every time a script is being executed > (every hit), which is very slow."
That's true, but only when you use dl() and not the extension= directive. AFAIK that's what the docs say too :) Derick
-- "my other box is your windows PC" ------------------------------------------------------------------------- Derick Rethans http://derickrethans.nl/ PHP Magazine - PHP Magazine for Professionals http://php-mag.net/ -------------------------------------------------------------------------