You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@perl.apache.org by Torsten Foertsch <to...@gmx.net> on 2007/11/14 17:34:48 UTC
about removing the last hash lookup in the interp management code
Hi Philippe,
in the threading branch this line and the corresponding get in
modperl_interp_pool_select() are the last occurrences of hash lookups in the
interp management.
(void)apr_pool_userdata_set((void *)r, "MODPERL_R", NULL, r->pool);
I am thinking of removing it. But it requires a extension to the request pool
and changes to the httpd.
The idea is to introduce typed pools with extensions. Something like
int type = apr_pool_type_register(void);
int ext = apr_pool_extension_register(int type, size_t size);
apr_pool_t *pool = apr_pool_create_typed_pool(int type);
void *ptr = apr_pool_get_extension(apr_pool_t *pool, int ext);
A call to apr_pool_type_register adds an element to some internal
apr_array_header_t and returns the index of the new element.
apr_pool_extension_register gets this index (or pool type) and increments said
array element by "size" rounded up to a proper alignment and returns the
value of the array element before the increment.
These 2 functions are to be called during initialization.
Then at runtime when a typed pool is needed pool structure is allocated plus
at the end of the pool enough space to hold all extensions. To access a
registered extension one calls apr_pool_get_extension which returns a pointer
to the amount of space registered during initialization.
In the httpd this would mean at init time:
extern int req_pool_type;
extern int conn_pool_type;
...
static int req_pool_type = apr_pool_type_register();
static int conn_pool_type = apr_pool_type_register();
...
Then the req pool creation is converted to
req_pool = apr_pool_create_typed_pool( req_pool_type )
In mod_perl this could look like:
INIT:
static my_req_pool_ext = apr_pool_extension_register(req_pool_type,
sizeof(void*));
RUNTIME:
void *ptr = apr_pool_get_extension(pool, my_req_pool_ext);
*ptr = (void *)r; /* instead of apr_pool_userdata_set */
I hope it is clear what I mean. I think not only mod_perl can benefit these
pool extensions. Apache would have to export the main pool types like
req_pool_type and conn_pool_type. Modules can add their own pool types.
Does that make sense? What are the odds on getting it into apr and apache?
Torsten
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org