php 8.1 jit 컴파일 옵션 사용하기
기본 설정이 opcache 사용으로 되어 있어서 페이지 로딩에서 보여지는 차이를 느끼지 못했습니다.
아래는 설정 및 확인한 내용 들입니다.
여기서 설치한 방법은 CentOS에서 php-fpm
아래 위치에서 환경설정 파일을 열어서 변경해 준다.
[root@pabburi /etc/opt/remi/php81] vim php.d/10-opcache.ini
#
# opcache.jit = 1205 - all code is JIT compiled
# opcache.jit = 1235 - only selected code portions (based on their relative use) are passed to the JIT compilation
# opcache.jit = 1255 - application code is tracked for compilation by JIT and selected parts of the code are transferred to the compiler
# opcache.jit = 1205 - 모든 코드가 JIT 컴파일됨
# opcache.jit = 1235 - 선택한 코드 부분(상대적 용도에 따라)만 JIT 컴파일에 전달됩니다.
# opcache.jit = 1255 - JIT에서 컴파일을 위해 애플리케이션 코드를 추적하고 코드의 선택된 부분을 컴파일러로 전송합니다.
#
# tracing은 1254, funciton은 1205과 같다
# https://www.php.net/manual/en/opcache.configuration.php#ini.opcache.jit
#
opcache.enable=1
opcache.enable_cli=1
opcache.jit_buffer_size=256M
opcache.jit=tracing
기본적인 환경설정에서는 jit 부분만 없고 인에이블은 이미 되어 있었다.
phpinfo를 확인해 보는 것이다.
현재 php8.1 사용인데 디폴트 옵션이 설정이 되어 있는 상태 임을 알 수 있다.
[root@pabburi /etc/opt/remi/php81] /opt/remi/php81/root/bin/php -r "phpinfo();" | grep opcache | grep jit
opcache.jit => tracing => tracing
opcache.jit_bisect_limit => 0 => 0
opcache.jit_blacklist_root_trace => 16 => 16
opcache.jit_blacklist_side_trace => 8 => 8
opcache.jit_buffer_size => 0 => 0
opcache.jit_debug => 0 => 0
opcache.jit_hot_func => 127 => 127
opcache.jit_hot_loop => 64 => 64
opcache.jit_hot_return => 8 => 8
opcache.jit_hot_side_exit => 8 => 8
opcache.jit_max_exit_counters => 8192 => 8192
opcache.jit_max_loop_unrolls => 8 => 8
opcache.jit_max_polymorphic_calls => 2 => 2
opcache.jit_max_recursive_calls => 2 => 2
opcache.jit_max_recursive_returns => 2 => 2
opcache.jit_max_root_traces => 1024 => 1024
opcache.jit_max_side_traces => 128 => 128
opcache.jit_prof_threshold => 0.005 => 0.005
이것 환경설정을 실시간으로 읽고 있다. php-fpm을 재시작하지 않아도 버퍼사이즈 변경하니 적용이 된다.
[root@pabburi /etc/opt/remi/php81] /opt/remi/php81/root/bin/php -r "phpinfo();" | grep opcache | grep jit
opcache.jit => tracing => tracing
opcache.jit_bisect_limit => 0 => 0
opcache.jit_blacklist_root_trace => 16 => 16
opcache.jit_blacklist_side_trace => 8 => 8
opcache.jit_buffer_size => 256M => 256M
opcache.jit_debug => 0 => 0
opcache.jit_hot_func => 127 => 127
opcache.jit_hot_loop => 64 => 64
opcache.jit_hot_return => 8 => 8
opcache.jit_hot_side_exit => 8 => 8
opcache.jit_max_exit_counters => 8192 => 8192
opcache.jit_max_loop_unrolls => 8 => 8
opcache.jit_max_polymorphic_calls => 2 => 2
opcache.jit_max_recursive_calls => 2 => 2
opcache.jit_max_recursive_returns => 2 => 2
opcache.jit_max_root_traces => 1024 => 1024
opcache.jit_max_side_traces => 128 => 128
opcache.jit_prof_threshold => 0.005 => 0.005
환경설정에 보면 아래와 같은것이 있다.
필요하지 아니한것은 정리해 놓으란 의미로 보면 될것 같다. 또는 문제가 발생 한다거나.
opcache.blacklist_filename=/etc/opt/remi/php81/php.d/opcache*.blacklist
결론은 실제 어느정도 속도 향상이 있는지에 대해서는 자신의 사이트는 자신이 비교 해야 될것입니다. 기본 옵션의 변경만 가지고 문제가 없는지 아니면 추가 적인 튜닝작업이 필요할지 말입니다. 아직 php81사용하고 있는것이 저 같은 경우는 트래픽이 많지 않아 이정도에서 마무리 지었습니다. 버퍼좀 늘려 줬으니 안한것 보다 낳겠지???
잘 사용하지 않는 레디스, 오디비씨 같은 모듈도 같이 설치 되면서 올라와 있는데 주석처리 하였는데 없어도 될것이 있어서 좋을 이유는 없습니다.
* 참고한곳
https://www.php.net/manual/en/opcache.configuration.php#ini.opcache.jit
https://www.phoronix.com/review/php8-jit-june/2
https://medium.com/jp-tech/try-out-jit-compiler-with-php-8-0-a020e6aeb3e5
https://www.droptica.com/blog/jit-compiler-php-8/