Searched hist:1376 (Results 1 – 2 of 2) sorted by relevance
/unit/auto/modules/ |
H A D | php | diff 1376:2ecb15904ba5 Tue Mar 03 14:38:00 UTC 2020 Tiago Natel de Moura <t.nateldemoura@f5.com> PHP: optimization to avoid surplus chdir(2) calls.
For each request, the worker calls the php_execute_script function from libphp that changes to the script directory before doing its work and then restores the process directory before returning. The chdir(2) calls it performs are unnecessary in Unit design. In simple benchmarks, profiling shows that the chdir syscall code path (syscall, FS walk, etc.) is where the CPU spends most of its time.
PHP SAPI semantics requires the script to be run from the script directory. In Unit's PHP implementation, we have two use cases:
- script - arbitrary path
The "script" configuration doesn't have much need for a working directory change: it can be changed once at module initialization. The module needs to chdir again only if the user's PHP script also calls chdir to switch to another directory during execution.
If "script" is not used in Unit configuration, we must ensure the script is run from its directory (thus calling chdir before exec), but there's no need to restore the working directory later.
Our implementation disables mandatory chdir calls with the SAPI option SAPI_OPTION_NO_CHDIR, instead calling chdir only when needed.
To detect the user's calls to chdir, a simple "unit" extension is added that hooks the built-in chdir() PHP call.
|
/unit/src/ |
H A D | nxt_php_sapi.c | diff 1376:2ecb15904ba5 Tue Mar 03 14:38:00 UTC 2020 Tiago Natel de Moura <t.nateldemoura@f5.com> PHP: optimization to avoid surplus chdir(2) calls.
For each request, the worker calls the php_execute_script function from libphp that changes to the script directory before doing its work and then restores the process directory before returning. The chdir(2) calls it performs are unnecessary in Unit design. In simple benchmarks, profiling shows that the chdir syscall code path (syscall, FS walk, etc.) is where the CPU spends most of its time.
PHP SAPI semantics requires the script to be run from the script directory. In Unit's PHP implementation, we have two use cases:
- script - arbitrary path
The "script" configuration doesn't have much need for a working directory change: it can be changed once at module initialization. The module needs to chdir again only if the user's PHP script also calls chdir to switch to another directory during execution.
If "script" is not used in Unit configuration, we must ensure the script is run from its directory (thus calling chdir before exec), but there's no need to restore the working directory later.
Our implementation disables mandatory chdir calls with the SAPI option SAPI_OPTION_NO_CHDIR, instead calling chdir only when needed.
To detect the user's calls to chdir, a simple "unit" extension is added that hooks the built-in chdir() PHP call.
|