Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiling php with modules vs using shared modules?

Tags:

php

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?

like image 904
ryeguy Avatar asked Aug 10 '09 13:08

ryeguy


3 Answers

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-extename? Functionnaly, there is no difference between the two. In practice, however, --enable is meant for features that can be turned on witout 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 additionnal 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.

like image 132
Pascal MARTIN Avatar answered Nov 01 '22 02:11

Pascal MARTIN


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.

like image 32
Benmouffok Mohammed Amine Avatar answered Nov 01 '22 04:11

Benmouffok Mohammed Amine


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.

like image 38
Chris Avatar answered Nov 01 '22 02:11

Chris