10

Is there a difference between compiling php with the parameter:

--with-[extension name]

as opposed to just compiling it as a shared module and including it that way? Is there any performance benefit? If not, why would you want to do this?

5 Answers 5

3

Maybe a difference in the memory footprint ?

Correct me if I am wrong but a built-in module will be duplicated in every process loaded in memory (because it's statically linked) whereas a shared module will be loaded only once and shared by all php process.

Sign up to request clarification or add additional context in comments.

Comments

3

Maybe it won't be a full answer to your question, but here's what I've been able to find so far : there is some kind of a partial answer in the book "Extending and Embedding PHP", written by Sara Golemon (amazon ; some parts are also available on google books).

The relevant part (a note at the top of page 56) is :

Ever wonder why some extensions are configured using --enable-extname and some are configured using --with-extname? Functionally, there is no difference between the two. In practice, however, --enable is meant for features that can be turned on without requiring any third-party libraries. --with, by contrast, is meant for features that do have such prerequisites.

So, not a single word about performance (I guess, if there is a difference, it is only a matter of "loading one more file" vs "loading one bigger file") ; but there is a technical reason behind this possibility.

I guess this is done so PHP itself doesn't require an additional external library because of some extension ; using the right option allows for users to enable or disable the extension themselves, depending on whether or not they already have that external library.

Comments

2

I have noticed when having all functions loaded as shared modules php pages load faster and cpu usage is lower, however some command line php functions dont work properly. Its logical to assume that a shared module setup is more ram efficent than a large static binary, as the modules would only be loaded when required.

Comments

0

Any performance benefit would be negligible. It’s simply another option for packaging up your PHP build.

On my Mac I use Marc Liyange’s build of PHP, which includes, among other things, built-in PostgreSQL support. It was built with the --with-pdo-pgsql flag. As a result it does not need to be distributed with the pdo-pgsql shared library.

If he did not build with --with-pdo-pgsql, he would have needed to distribute the pdo-pgsql shared library and include a directive in php.ini to load it. Sure, it’s just a minor difference, but if you know you are going to be using that functionality, it’s fine to build it into PHP itself.

Comments

0

I guess Nate is right about the performance and that this options only help for packing.

Basically with a compiled-in module PHP can call directly the module functions, but, after the compilation, this calls are translated into memory addresses to be called.

In the loadable module version, PHP will call a dl_open to load the library and then call the functions by there addresses, juts like the compiled-in version does. I guess that this dl_open call is done only once when the webserver is started, so you can ignore it.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.