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

51

Upload: yoshio-hanawa

Post on 16-Apr-2017

4.832 views

Category:

Technology


0 download

TRANSCRIPT

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

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

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

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

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

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

❖ *.php

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

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

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

❖ *.php

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

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()

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

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()

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

❖ *.php

❖ stat(2)

❖ stat

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

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

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

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

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

❖ *.php

❖ stat(2)

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

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

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

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

❖ *.php

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

*.php

❖ *.php

❖ *.php

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

❖ realpath_cache_ttl

❖ *.php

❖ realpath_cache_ttl=0

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

❖ *.php

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

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

❖ *.php

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

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

❖ opcache.revalidate_path=0

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

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

php_execute_script(&file_handle);

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

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

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;

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

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;

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

❖ php_execute_script() file_handle->opened_path

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

❖ file_handle->opened_pathdo_validate_timetamps()

❖ opcache.validate_timestamps=1

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

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

❖ opcache.revalidate_path=0

❖ opcache.revalidate_path=1

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

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

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

❖ $realpath_root

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

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

❖ opcache.revalidate_path=0

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

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

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

❖ opcache.max_accelerated_files❖

❖ opcache_get_status()

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

❖ opcache.max_wasted_percentage❖

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

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

❖ opcache_invalidate($script)

❖ opcache_reset()

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

❖ $realpath_root opcache_invalidate()

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

❖ opcache.revalidate_path=1

❖ realpath_cache_ttl=5

❖ opcache.revalidate_path=0

❖ opcache.validate_timestamps=0

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

❖ opcache_reset()

Page 49: realpathキャッシュと OPcacheの面倒すぎる関係
Page 50: realpathキャッシュと OPcacheの面倒すぎる関係
Page 51: realpathキャッシュと OPcacheの面倒すぎる関係

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

/* autoloader */