# add_*_vars() speed-up

- Thread: https://externals.io/message/22487
- Original archive: https://news-web.php.net/php.internals/22487
- Started by Andrei Zmievski on 2006-03-16T22:47:15+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #22487 — Andrei Zmievski — 2006-03-16T22:47:15+00:00

URL: https://externals.io/message/22487#22487

Based on Rasmus's profiling efforts, we have determined that 
add_cgi_vars() and add_common_vars() are taking a lot of time. Having 
taken a look at their implementation it seems that they are doing some 
unnecessary stuff, like creating a temporary table, filling it with 
entries and then calling ap_overlap_tables() which is supposed to 
overlap it over r->subprocess_env. But r->subprocess_env contains only 
a couple of entries by the time add_common_vars() is called, so it 
would be faster to add entries to it directly. Also, add_cgi_vars() was 
doing a subrequest in case r->path_info was present, which is 
completely unneeded for PHP as Apache module.

The solution is to duplicate the functionality of these functions in 
mod_php5.c which is what the attached patch does. It also sets 
PATH_TRANSLATED in r->subprocess_env directly, so 
sapi_apache_register_server_variables() does not need to special case 
it.

Please look it over and test. It seems to give about 7% boost on 
average.

-Andrei

---

## #22495 — Dmitry Stogov — 2006-03-17T07:25:39+00:00

URL: https://externals.io/message/22487#22495 · In reply to: #22487

Hi Andrei,

I don't see AUTH_USER, HTTPS..., CLIENT_CERT, HTTP_HOST, REQUEST_LINE,
SERVER_URL.

May be not all of them necessary and available in apache, but AUTH_USER,
HTTPS are required for PHP.

Thanks. Dmitry.

> -----Original Message-----
> From: Andrei Zmievski [mailto:andrei@gravitonic.com] 
> Sent: Friday, March 17, 2006 1:47 AM
> To: php internals
> Subject: [PHP-DEV] add_*_vars() speed-up
> 
> 
> Based on Rasmus's profiling efforts, we have determined that 
> add_cgi_vars() and add_common_vars() are taking a lot of time. Having 
> taken a look at their implementation it seems that they are 
> doing some 
> unnecessary stuff, like creating a temporary table, filling it with 
> entries and then calling ap_overlap_tables() which is supposed to 
> overlap it over r->subprocess_env. But r->subprocess_env 
> contains only 
> a couple of entries by the time add_common_vars() is called, so it 
> would be faster to add entries to it directly. Also, 
> add_cgi_vars() was 
> doing a subrequest in case r->path_info was present, which is 
> completely unneeded for PHP as Apache module.
> 
> The solution is to duplicate the functionality of these functions in 
> mod_php5.c which is what the attached patch does. It also sets 
> PATH_TRANSLATED in r->subprocess_env directly, so 
> sapi_apache_register_server_variables() does not need to special case 
> it.
> 
> Please look it over and test. It seems to give about 7% boost on 
> average.
> 
> -Andrei
