realpathキャッシュと OPcacheの面倒すぎる関係
-
Upload
yoshio-hanawa -
Category
Technology
-
view
4.832 -
download
0
Transcript of realpathキャッシュと OPcacheの面倒すぎる関係
![Page 1: realpathキャッシュと OPcacheの面倒すぎる関係](https://reader031.fdocument.pub/reader031/viewer/2022021507/587067f81a28ab48378b558d/html5/thumbnails/1.jpg)
![Page 2: realpathキャッシュと OPcacheの面倒すぎる関係](https://reader031.fdocument.pub/reader031/viewer/2022021507/587067f81a28ab48378b558d/html5/thumbnails/2.jpg)
❖
❖
❖
❖
![Page 3: realpathキャッシュと OPcacheの面倒すぎる関係](https://reader031.fdocument.pub/reader031/viewer/2022021507/587067f81a28ab48378b558d/html5/thumbnails/3.jpg)
❖
❖
![Page 4: realpathキャッシュと OPcacheの面倒すぎる関係](https://reader031.fdocument.pub/reader031/viewer/2022021507/587067f81a28ab48378b558d/html5/thumbnails/4.jpg)
❖
❖
![Page 5: realpathキャッシュと OPcacheの面倒すぎる関係](https://reader031.fdocument.pub/reader031/viewer/2022021507/587067f81a28ab48378b558d/html5/thumbnails/5.jpg)
❖
❖
❖
❖
❖
![Page 6: realpathキャッシュと OPcacheの面倒すぎる関係](https://reader031.fdocument.pub/reader031/viewer/2022021507/587067f81a28ab48378b558d/html5/thumbnails/6.jpg)
❖
❖
❖
❖
❖
![Page 7: realpathキャッシュと OPcacheの面倒すぎる関係](https://reader031.fdocument.pub/reader031/viewer/2022021507/587067f81a28ab48378b558d/html5/thumbnails/7.jpg)
❖ *.php
❖
❖
❖
❖
![Page 8: realpathキャッシュと OPcacheの面倒すぎる関係](https://reader031.fdocument.pub/reader031/viewer/2022021507/587067f81a28ab48378b558d/html5/thumbnails/8.jpg)
<?phprequire_once("/foo/bar/baz.php");require_once("bar/baz.php");require_once("baz.php");
❖
❖
❖
![Page 9: realpathキャッシュと OPcacheの面倒すぎる関係](https://reader031.fdocument.pub/reader031/viewer/2022021507/587067f81a28ab48378b558d/html5/thumbnails/9.jpg)
❖ *.php
❖
![Page 10: realpathキャッシュと OPcacheの面倒すぎる関係](https://reader031.fdocument.pub/reader031/viewer/2022021507/587067f81a28ab48378b558d/html5/thumbnails/10.jpg)
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の面倒すぎる関係](https://reader031.fdocument.pub/reader031/viewer/2022021507/587067f81a28ab48378b558d/html5/thumbnails/11.jpg)
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の面倒すぎる関係](https://reader031.fdocument.pub/reader031/viewer/2022021507/587067f81a28ab48378b558d/html5/thumbnails/12.jpg)
❖ *.php
❖ stat(2)
❖ stat
❖
![Page 13: realpathキャッシュと OPcacheの面倒すぎる関係](https://reader031.fdocument.pub/reader031/viewer/2022021507/587067f81a28ab48378b558d/html5/thumbnails/13.jpg)
❖
❖
❖
$ pstree 35811-+= 35811 hnw sapi/fpm/php-fpm |--- 35812 hnw sapi/fpm/php-fpm \--- 35813 hnw sapi/fpm/php-fpm
![Page 14: realpathキャッシュと OPcacheの面倒すぎる関係](https://reader031.fdocument.pub/reader031/viewer/2022021507/587067f81a28ab48378b558d/html5/thumbnails/14.jpg)
❖
❖
❖
$ pstree 35811-+= 35811 hnw sapi/fpm/php-fpm |--- 35812 hnw sapi/fpm/php-fpm \--- 35813 hnw sapi/fpm/php-fpm
![Page 15: realpathキャッシュと OPcacheの面倒すぎる関係](https://reader031.fdocument.pub/reader031/viewer/2022021507/587067f81a28ab48378b558d/html5/thumbnails/15.jpg)
❖ *.php
❖ stat(2)
❖
❖
❖
![Page 16: realpathキャッシュと OPcacheの面倒すぎる関係](https://reader031.fdocument.pub/reader031/viewer/2022021507/587067f81a28ab48378b558d/html5/thumbnails/16.jpg)
❖
❖
❖
❖
❖
![Page 17: realpathキャッシュと OPcacheの面倒すぎる関係](https://reader031.fdocument.pub/reader031/viewer/2022021507/587067f81a28ab48378b558d/html5/thumbnails/17.jpg)
!"" current -> /var/www/my_app_name/releases/20150120114500/!"" releases# !"" 20150100093500# !"" 20150110104000# $"" 20150120114500
❖
❖
![Page 18: realpathキャッシュと OPcacheの面倒すぎる関係](https://reader031.fdocument.pub/reader031/viewer/2022021507/587067f81a28ab48378b558d/html5/thumbnails/18.jpg)
❖
❖ *.php
❖
❖
❖
❖
![Page 19: realpathキャッシュと OPcacheの面倒すぎる関係](https://reader031.fdocument.pub/reader031/viewer/2022021507/587067f81a28ab48378b558d/html5/thumbnails/19.jpg)
❖
*.php
❖ *.php
❖ *.php
❖
❖
![Page 20: realpathキャッシュと OPcacheの面倒すぎる関係](https://reader031.fdocument.pub/reader031/viewer/2022021507/587067f81a28ab48378b558d/html5/thumbnails/20.jpg)
❖ realpath_cache_ttl
❖
❖ *.php
❖
❖
❖ realpath_cache_ttl=0
![Page 21: realpathキャッシュと OPcacheの面倒すぎる関係](https://reader031.fdocument.pub/reader031/viewer/2022021507/587067f81a28ab48378b558d/html5/thumbnails/21.jpg)
❖
❖ *.php
❖
❖
![Page 22: realpathキャッシュと OPcacheの面倒すぎる関係](https://reader031.fdocument.pub/reader031/viewer/2022021507/587067f81a28ab48378b558d/html5/thumbnails/22.jpg)
❖
❖
❖
❖
❖
![Page 23: realpathキャッシュと OPcacheの面倒すぎる関係](https://reader031.fdocument.pub/reader031/viewer/2022021507/587067f81a28ab48378b558d/html5/thumbnails/23.jpg)
❖
❖ *.php
❖
❖
❖
![Page 25: realpathキャッシュと OPcacheの面倒すぎる関係](https://reader031.fdocument.pub/reader031/viewer/2022021507/587067f81a28ab48378b558d/html5/thumbnails/25.jpg)
❖
❖
❖
![Page 26: realpathキャッシュと OPcacheの面倒すぎる関係](https://reader031.fdocument.pub/reader031/viewer/2022021507/587067f81a28ab48378b558d/html5/thumbnails/26.jpg)
❖ opcache.revalidate_path=0
❖
❖
❖
❖
![Page 27: realpathキャッシュと OPcacheの面倒すぎる関係](https://reader031.fdocument.pub/reader031/viewer/2022021507/587067f81a28ab48378b558d/html5/thumbnails/27.jpg)
❖
❖
❖
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の面倒すぎる関係](https://reader031.fdocument.pub/reader031/viewer/2022021507/587067f81a28ab48378b558d/html5/thumbnails/28.jpg)
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の面倒すぎる関係](https://reader031.fdocument.pub/reader031/viewer/2022021507/587067f81a28ab48378b558d/html5/thumbnails/29.jpg)
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の面倒すぎる関係](https://reader031.fdocument.pub/reader031/viewer/2022021507/587067f81a28ab48378b558d/html5/thumbnails/30.jpg)
❖ php_execute_script() file_handle->opened_path
❖
❖
![Page 31: realpathキャッシュと OPcacheの面倒すぎる関係](https://reader031.fdocument.pub/reader031/viewer/2022021507/587067f81a28ab48378b558d/html5/thumbnails/31.jpg)
❖ file_handle->opened_pathdo_validate_timetamps()
❖
❖
❖ opcache.validate_timestamps=1
![Page 32: realpathキャッシュと OPcacheの面倒すぎる関係](https://reader031.fdocument.pub/reader031/viewer/2022021507/587067f81a28ab48378b558d/html5/thumbnails/32.jpg)
❖
❖
❖
❖
![Page 33: realpathキャッシュと OPcacheの面倒すぎる関係](https://reader031.fdocument.pub/reader031/viewer/2022021507/587067f81a28ab48378b558d/html5/thumbnails/33.jpg)
❖ opcache.revalidate_path=0
❖
❖ opcache.revalidate_path=1
❖
❖
❖
![Page 34: realpathキャッシュと OPcacheの面倒すぎる関係](https://reader031.fdocument.pub/reader031/viewer/2022021507/587067f81a28ab48378b558d/html5/thumbnails/34.jpg)
❖
❖
❖
❖
❖
![Page 36: realpathキャッシュと OPcacheの面倒すぎる関係](https://reader031.fdocument.pub/reader031/viewer/2022021507/587067f81a28ab48378b558d/html5/thumbnails/36.jpg)
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;fastcgi_param DOCUMENT_ROOT $realpath_root;
❖
❖ $realpath_root
❖
![Page 38: realpathキャッシュと OPcacheの面倒すぎる関係](https://reader031.fdocument.pub/reader031/viewer/2022021507/587067f81a28ab48378b558d/html5/thumbnails/38.jpg)
❖
❖
❖
❖
![Page 39: realpathキャッシュと OPcacheの面倒すぎる関係](https://reader031.fdocument.pub/reader031/viewer/2022021507/587067f81a28ab48378b558d/html5/thumbnails/39.jpg)
❖
❖
❖ opcache.revalidate_path=0
❖
❖
❖
![Page 40: realpathキャッシュと OPcacheの面倒すぎる関係](https://reader031.fdocument.pub/reader031/viewer/2022021507/587067f81a28ab48378b558d/html5/thumbnails/40.jpg)
❖
❖
❖
❖
❖
![Page 41: realpathキャッシュと OPcacheの面倒すぎる関係](https://reader031.fdocument.pub/reader031/viewer/2022021507/587067f81a28ab48378b558d/html5/thumbnails/41.jpg)
❖
❖
❖
❖
❖
![Page 42: realpathキャッシュと OPcacheの面倒すぎる関係](https://reader031.fdocument.pub/reader031/viewer/2022021507/587067f81a28ab48378b558d/html5/thumbnails/42.jpg)
❖ opcache.max_accelerated_files❖
❖
❖ opcache_get_status()
![Page 43: realpathキャッシュと OPcacheの面倒すぎる関係](https://reader031.fdocument.pub/reader031/viewer/2022021507/587067f81a28ab48378b558d/html5/thumbnails/43.jpg)
❖ opcache.max_wasted_percentage❖
❖
❖
❖
![Page 44: realpathキャッシュと OPcacheの面倒すぎる関係](https://reader031.fdocument.pub/reader031/viewer/2022021507/587067f81a28ab48378b558d/html5/thumbnails/44.jpg)
❖
❖
❖
❖
❖
![Page 45: realpathキャッシュと OPcacheの面倒すぎる関係](https://reader031.fdocument.pub/reader031/viewer/2022021507/587067f81a28ab48378b558d/html5/thumbnails/45.jpg)
❖ opcache_invalidate($script)
❖
❖
❖ opcache_reset()
❖
![Page 46: realpathキャッシュと OPcacheの面倒すぎる関係](https://reader031.fdocument.pub/reader031/viewer/2022021507/587067f81a28ab48378b558d/html5/thumbnails/46.jpg)
❖
❖
❖ $realpath_root opcache_invalidate()
❖
❖
❖
![Page 47: realpathキャッシュと OPcacheの面倒すぎる関係](https://reader031.fdocument.pub/reader031/viewer/2022021507/587067f81a28ab48378b558d/html5/thumbnails/47.jpg)
❖
❖ opcache.revalidate_path=1
❖ realpath_cache_ttl=5
❖
❖ opcache.revalidate_path=0
❖ opcache.validate_timestamps=0
![Page 48: realpathキャッシュと OPcacheの面倒すぎる関係](https://reader031.fdocument.pub/reader031/viewer/2022021507/587067f81a28ab48378b558d/html5/thumbnails/48.jpg)
❖
❖
❖
❖ opcache_reset()
![Page 49: realpathキャッシュと OPcacheの面倒すぎる関係](https://reader031.fdocument.pub/reader031/viewer/2022021507/587067f81a28ab48378b558d/html5/thumbnails/49.jpg)
![Page 50: realpathキャッシュと OPcacheの面倒すぎる関係](https://reader031.fdocument.pub/reader031/viewer/2022021507/587067f81a28ab48378b558d/html5/thumbnails/50.jpg)
![Page 51: realpathキャッシュと OPcacheの面倒すぎる関係](https://reader031.fdocument.pub/reader031/viewer/2022021507/587067f81a28ab48378b558d/html5/thumbnails/51.jpg)
<?phpdefine('ROOT_DIR', getcwd()); /* dirname(__FILE__) */
/* autoloader */
❖
❖
❖
❖