[nycphp-talk] problems loading a custom, shared extension
Hans Zaunere
lists at zaunere.com
Fri Jan 6 20:35:20 EST 2006
Jonathan wrote on Tuesday, January 03, 2006 2:18 PM:
> Following up... the shared object now loads and works properly!
>
> Hans, thanks for the tip - it proved to be correct.
> In php4 the only error on loading the extension was that it wasn't a
> valid PHP extension.
> Under php 5 a better error appears warning precisely :
>
> "PHP Warning: PHP Startup: (null): Unable to initialize module
> Module compiled with module API=20050922, debug=1, thread-safety=0
> PHP compiled with module API=20041030, debug=0, thread-safety=0
> These options need to match."
Great - good to hear it worked...
> In running the function in a loop it is 3x faster than php functionality
> I am replacing.
Interesting - figured it'd be faster, but then again, depending on what it's
doing and the rest of the application, I could understand these findings.
> However, when testing with apache ab to more accurately simulate real
> world conditions it is the same speed as the php functionality I am
> replacing. I load the extension in the php.ini file which is about twice
> as fast as using dl() to load the extension.
Heh - don't let certain people hear that :)
> I've learned from this exercise that PHP is written to be fast.
> Any obvious reason that an extension function run a loop is faster than
> an extension which is loaded through the INI?
You mean why the .ini loaded extension is faster than dl() loaded?
It's hard to say actualy. AFAIK, while the dl() might take a little longer,
once it's loaded, it should run the same. Now there is the age old debate
about the consequence of shared code, PIC, dynamically loaded .so and all
that good voodoo, but at the end of the day, I think the computer is the
only one who really knows.
That said, I try to "hardwire" things where possible, rather than loading on
the fly (extensions, userland PHP, etc) as I've generally found more
reliable behavior, let alone performance.
---
Hans Zaunere / President / New York PHP
www.nyphp.org / www.nyphp.com
More information about the talk
mailing list