You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Torsten Förtsch <to...@gmx.net> on 2011/04/11 20:45:55 UTC

ap_read_config in 2.3.11

Hi,

I am working on porting modperl to the upcoming httpd 2.4. One problem is the 
line

  conf_vector_length = total_modules;

in ap_read_config (config.c:2300).

Modperl provides a way to write modules in Perl. These modules are loaded by 
the directive PerlLoadModule which is executed later than line 2300. Such 
modules are then appended to the module list, get a module structure, can 
create config directives etc. They also have a module index and allocate their 
place in config vectors.

Now, the line above limits the config vector length to the number of modules 
known before any one perl module could be loaded.

How can this situation be solved?

Thanks,
Torsten Förtsch

-- 
Need professional modperl support? Hire me! (http://foertsch.name)

Like fantasy? http://kabatinte.net

Re: ap_read_config in 2.3.11

Posted by Torsten Förtsch <to...@gmx.net>.
On Monday, April 11, 2011 21:14:53 Stefan Fritsch wrote:
> I guess the optimization could be done later, after the config has 
> been parsed completely. That would waste some memory in pconf but 
> still preserve the optimization during request processing, which is 
> more important.

The enclosed patch moves the conf_vector_length adjustment to when 
ap_process_config_tree() has done its work. I think that is enough for 
mod_perl.

On Tuesday, April 12, 2011 18:24:28 William A. Rowe Jr. wrote:
> Suggestion - an EXEC_ON_READ 'DynamicModulesMax' directive, which would
> let us conf_vector_length = total_modules + dyn_modules_max; after the
> read_config, and finally lock down conf_vector_length = total_modules;
> at the end of post_config.  WDYT?

But yes, moving the adjustment to postconfig will solve the problem more 
generally. I'll see if I can conceive a patch.

Torsten Förtsch

-- 
Need professional modperl support? Hire me! (http://foertsch.name)

Like fantasy? http://kabatinte.net

Re: ap_read_config in 2.3.11

Posted by Stefan Fritsch <sf...@sfritsch.de>.
On Monday 25 April 2011, Torsten Förtsch wrote:
> Thanks a lot! It seems your patch works flawlessly after I figured
> out  another bug in the modperl test suite.

Thanks for testing. Committed as r1096569


Re: ap_read_config in 2.3.11

Posted by Torsten Förtsch <to...@gmx.net>.
On Tuesday, April 19, 2011 23:35:23 Stefan Fritsch wrote:
> The attached patch adds two functions, ap_reserve_module_slots() and 
> ap_reserve_module_slots_directive(), which can be called by relevant 
> modules in the pre config stage.
> 
> Can you please test this patch and call 
> ap_reserve_module_slots_directive("PerlLoadModule") in mod_perl's 
> pre_config hook?

Thanks a lot! It seems your patch works flawlessly after I figured out 
another bug in the modperl test suite.

Torsten Förtsch

-- 
Need professional modperl support? Hire me! (http://foertsch.name)

Like fantasy? http://kabatinte.net

Re: ap_read_config in 2.3.11

Posted by Stefan Fritsch <sf...@sfritsch.de>.
On Monday 18 April 2011, Stefan Fritsch wrote:
> I don't really like that. The admin should not have to count the
> LoadModule directives in order to tune DynamicModulesMax for
> minimum memory usage. Httpd should do the counting.

> - a module that wants to add modules later (like mod_perl) could
> call some function in its insert_hooks function, which would cause
> the adjustment of conf_vector_length to happen in post_config
> instead

The attached patch adds two functions, ap_reserve_module_slots() and 
ap_reserve_module_slots_directive(), which can be called by relevant 
modules in the pre config stage.

Can you please test this patch and call 
ap_reserve_module_slots_directive("PerlLoadModule") in mod_perl's 
pre_config hook?

Re: ap_read_config in 2.3.11

Posted by Stefan Fritsch <sf...@sfritsch.de>.
On Sunday 17 April 2011, Torsten Förtsch wrote:
> On Tuesday, April 12, 2011 18:24:28 William A. Rowe Jr. wrote:
> > Suggestion - an EXEC_ON_READ 'DynamicModulesMax' directive, which
> > would let us conf_vector_length = total_modules +
> > dyn_modules_max; after the read_config, and finally lock down
> > conf_vector_length = total_modules; at the end of post_config. 
> > WDYT?
> 
> The attached patch implements the DynamicModulesMax directive. It
> can appear anywhere in the config file but is best placed *before*
> any LoadModule directive. Up to post_config the number of
> prelinked modules plus DynamicModulesMax is used as
> conf_vector_length. In core_post_config the length is then settled
> on total_modules.

I don't really like that. The admin should not have to count the 
LoadModule directives in order to tune DynamicModulesMax for minimum 
memory usage. Httpd should do the counting.

Maybe something like this:

- normally, conf_vector_length is adjusted after all EXEC_ON_READ 
directives have been processed
- a module that wants to add modules later (like mod_perl) could call 
some function in its insert_hooks function, which would cause the 
adjustment of conf_vector_length to happen in post_config instead

The function to be called could optionally take a number of module 
slots that should be kept in reserve. Then conf_vector_length would be 
adjusted to total_modules + reserve after all EXEC_ON_READ is done, 
and to total_modules in post_config. Or maybe the reserve should 
simply be set by some new directive like DynamicModulesMax?

What do you think?

BTW, I think there is something fishy with PerlLoadModule (or at least 
the documentation): The docs says that perl modules can use 
Apache2::Const::EXEC_ON_READ, but this cannot work because 
PerlLoadModule itself is executed too late.

Cheers,
Stefan

Re: ap_read_config in 2.3.11

Posted by Torsten Förtsch <to...@gmx.net>.
On Tuesday, April 12, 2011 18:24:28 William A. Rowe Jr. wrote:
> Suggestion - an EXEC_ON_READ 'DynamicModulesMax' directive, which would
> let us conf_vector_length = total_modules + dyn_modules_max; after the
> read_config, and finally lock down conf_vector_length = total_modules;
> at the end of post_config.  WDYT?

The attached patch implements the DynamicModulesMax directive. It can appear 
anywhere in the config file but is best placed *before* any LoadModule 
directive. Up to post_config the number of prelinked modules plus 
DynamicModulesMax is used as conf_vector_length. In core_post_config the 
length is then settled on total_modules.

Torsten Förtsch

-- 
Need professional modperl support? Hire me! (http://foertsch.name)

Like fantasy? http://kabatinte.net

Re: ap_read_config in 2.3.11

Posted by "William A. Rowe Jr." <wr...@rowe-clan.net>.
On 4/11/2011 2:14 PM, Stefan Fritsch wrote:
> On Monday 11 April 2011, Torsten Förtsch wrote:
>> I am working on porting modperl to the upcoming httpd 2.4. One
>> problem is the line
>>
>>   conf_vector_length = total_modules;
>>
>> in ap_read_config (config.c:2300).
>>
>> Modperl provides a way to write modules in Perl. These modules are
>> loaded by the directive PerlLoadModule which is executed later
>> than line 2300. Such modules are then appended to the module list,
>> get a module structure, can create config directives etc. They
>> also have a module index and allocate their place in config
>> vectors.
>>
>> Now, the line above limits the config vector length to the number
>> of modules known before any one perl module could be loaded.
>>
>> How can this situation be solved?
> 
> When exactly is PerlLoadModule executed? The above code assumes that 
> modules are loaded with EXEC_ON_READ during reading of the config.
> 
> I guess the optimization could be done later, after the config has 
> been parsed completely. That would waste some memory in pconf but 
> still preserve the optimization during request processing, which is 
> more important.

Suggestion - an EXEC_ON_READ 'DynamicModulesMax' directive, which would
let us conf_vector_length = total_modules + dyn_modules_max; after the
read_config, and finally lock down conf_vector_length = total_modules;
at the end of post_config.  WDYT?


Re: ap_read_config in 2.3.11

Posted by Stefan Fritsch <sf...@sfritsch.de>.
On Monday 11 April 2011, Torsten Förtsch wrote:
> I am working on porting modperl to the upcoming httpd 2.4. One
> problem is the line
> 
>   conf_vector_length = total_modules;
> 
> in ap_read_config (config.c:2300).
> 
> Modperl provides a way to write modules in Perl. These modules are
> loaded by the directive PerlLoadModule which is executed later
> than line 2300. Such modules are then appended to the module list,
> get a module structure, can create config directives etc. They
> also have a module index and allocate their place in config
> vectors.
> 
> Now, the line above limits the config vector length to the number
> of modules known before any one perl module could be loaded.
> 
> How can this situation be solved?

When exactly is PerlLoadModule executed? The above code assumes that 
modules are loaded with EXEC_ON_READ during reading of the config.

I guess the optimization could be done later, after the config has 
been parsed completely. That would waste some memory in pconf but 
still preserve the optimization during request processing, which is 
more important.