summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_conf_validation.c
diff options
context:
space:
mode:
authorTiago Natel de Moura <t.nateldemoura@f5.com>2020-03-03 14:38:08 +0000
committerTiago Natel de Moura <t.nateldemoura@f5.com>2020-03-03 14:38:08 +0000
commitf99d20ad39a62cf30b6b0b01593336572484f4f5 (patch)
treef1db56f1c22d1d1f4a1d6892ce9befdd7cf9ba6a /src/nxt_conf_validation.c
parent9e295fa3141e8deec7813ea4e0c6fa57d4a87bd8 (diff)
downloadunit-f99d20ad39a62cf30b6b0b01593336572484f4f5.tar.gz
unit-f99d20ad39a62cf30b6b0b01593336572484f4f5.tar.bz2
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.
Diffstat (limited to 'src/nxt_conf_validation.c')
0 files changed, 0 insertions, 0 deletions