realpathキャッシュと OPcacheの面倒すぎる関係

Preview:

Citation preview

❖ *.php

<?phprequire_once("/foo/bar/baz.php");require_once("bar/baz.php");require_once("baz.php");

❖ *.php

switch (type) { case ZEND_INCLUDE_ONCE: case ZEND_REQUIRE_ONCE: { zend_file_handle file_handle; zend_string *resolved_path;

resolved_path = zend_resolve_path(Z_STRVAL_P(inc_filename), (int)Z_STRLEN_P(inc_filename)); if (resolved_path) { if (zend_hash_exists(&EG(included_files), resolved_path)) { goto already_compiled; }

Zend/zend_execute.c zend_include_or_eval()

switch (type) { case ZEND_INCLUDE_ONCE: case ZEND_REQUIRE_ONCE: { zend_file_handle file_handle; zend_string *resolved_path;

resolved_path = zend_resolve_path(Z_STRVAL_P(inc_filename), (int)Z_STRLEN_P(inc_filename)); if (resolved_path) { if (zend_hash_exists(&EG(included_files), resolved_path)) { goto already_compiled; }

Zend/zend_execute.c zend_include_or_eval()

❖ *.php

❖ stat(2)

❖ stat

$ pstree 35811-+= 35811 hnw sapi/fpm/php-fpm |--- 35812 hnw sapi/fpm/php-fpm \--- 35813 hnw sapi/fpm/php-fpm

$ pstree 35811-+= 35811 hnw sapi/fpm/php-fpm |--- 35812 hnw sapi/fpm/php-fpm \--- 35813 hnw sapi/fpm/php-fpm

❖ *.php

❖ stat(2)

!"" current -> /var/www/my_app_name/releases/20150120114500/!"" releases# !"" 20150100093500# !"" 20150110104000# $"" 20150120114500

❖ *.php

*.php

❖ *.php

❖ *.php

❖ realpath_cache_ttl

❖ *.php

❖ realpath_cache_ttl=0

❖ *.php

❖ *.php

❖ opcache.revalidate_path=0

int main(int argc, char *argv[]){ /* */

php_execute_script(&file_handle);

sapi/fpm/fpm/fpm_main.c sapi/apache2handler/sapi_apache2.c

typedef struct _zend_file_handle { union { int fd; FILE *fp; zend_stream stream; } handle; const char *filename; zend_string *opened_path; zend_stream_type type; zend_bool free_filename;} zend_file_handle;

typedef struct _zend_file_handle { union { int fd; FILE *fp; zend_stream stream; } handle; const char *filename; zend_string *opened_path; zend_stream_type type; zend_bool free_filename;} zend_file_handle;

❖ php_execute_script() file_handle->opened_path

❖ file_handle->opened_pathdo_validate_timetamps()

❖ opcache.validate_timestamps=1

❖ opcache.revalidate_path=0

❖ opcache.revalidate_path=1

fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;fastcgi_param DOCUMENT_ROOT $realpath_root;

❖ $realpath_root

❖ opcache.revalidate_path=0

❖ opcache.max_accelerated_files❖

❖ opcache_get_status()

❖ opcache.max_wasted_percentage❖

❖ opcache_invalidate($script)

❖ opcache_reset()

❖ $realpath_root opcache_invalidate()

❖ opcache.revalidate_path=1

❖ realpath_cache_ttl=5

❖ opcache.revalidate_path=0

❖ opcache.validate_timestamps=0

❖ opcache_reset()

<?phpdefine('ROOT_DIR', getcwd()); /* dirname(__FILE__) */

/* autoloader */

Recommended