Get the most out of your Centmin Mod LEMP stack
Become a Member

PHP PHP 8 Enabling JIT

Discussion in 'Nginx and PHP-FPM news & discussions' started by happyhacking, Jan 24, 2023.

  1. happyhacking

    happyhacking Premium Member Premium Member

    111
    18
    18
    Apr 23, 2021
    Ratings:
    +61
    Local Time:
    11:50 AM
    1.22.0
    MariadDB 10.4.25
    Im posting this because isnt clear how to enable PHP JIT optimizations, im not sure if they are enabled by default or we need to do some config with opcache.jit variable. Any clarification on this matter would be appreciated. thanks

     
  2. happyhacking

    happyhacking Premium Member Premium Member

    111
    18
    18
    Apr 23, 2021
    Ratings:
    +61
    Local Time:
    11:50 AM
    1.22.0
    MariadDB 10.4.25
    For the ppl who likes easy way and the TL,DR here is my JIT config used in production:
    Code:
    @/etc/centminmod/php.d/b_customphp.ini
    
    ; Enables the opcode cache for the CLI version of PHP.
    opcache.enable_cli=1
    ; JIT Flags, function=1205, tracing=1254
    opcache.jit=1254
    ; The amount of shared memory to reserve for compiled JIT code. A zero value disables the JIT.
    opcache.jit_buffer_size=480M
    
     
  3. pamamolf

    pamamolf Well-Known Member

    4,041
    427
    83
    May 31, 2014
    Ratings:
    +825
    Local Time:
    7:50 PM
    Nginx-1.25.x
    MariaDB 10.3.x
    Is a restart enough for this or a recompile is needed?
     
  4. happyhacking

    happyhacking Premium Member Premium Member

    111
    18
    18
    Apr 23, 2021
    Ratings:
    +61
    Local Time:
    11:50 AM
    1.22.0
    MariadDB 10.4.25
    “nprestart” should be enough.
     
  5. pamamolf

    pamamolf Well-Known Member

    4,041
    427
    83
    May 31, 2014
    Ratings:
    +825
    Local Time:
    7:50 PM
    Nginx-1.25.x
    MariaDB 10.3.x
    But to benefit from JIT the software should be developed using JIT in mind and is not something that can be done by php on any code correct?
     
  6. happyhacking

    happyhacking Premium Member Premium Member

    111
    18
    18
    Apr 23, 2021
    Ratings:
    +61
    Local Time:
    11:50 AM
    1.22.0
    MariadDB 10.4.25
    No, the JIT are some kind of optimizations for the PHP 8 compiler, that are automatically used by the opcache module, some of them are assembler or machine code optimized for common functions.
     
    Last edited: Feb 15, 2023
  7. eva2000

    eva2000 Administrator Staff Member

    51,632
    11,935
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,423
    Local Time:
    2:50 AM
    Nginx 1.25.x
    MariaDB 10.x
    PHP service restart is enough.

    ChatGPT assisted reply :D

    PHP 8 JIT (Just-In-Time Compiler) is a new feature introduced in PHP 8, which is an open-source programming language used for server-side web development. JIT is a performance optimization technique that compiles the source code of a program into machine code just before it is executed, instead of ahead of time. The JIT compiler in PHP 8 can significantly improve the performance of PHP scripts by compiling the most frequently executed code into machine code at runtime.

    The Just-In-Time Compiler in PHP 8 can benefit a variety of use cases, but its biggest impact will likely be seen in the following scenarios:
    1. Computationally intensive applications: Applications that perform a lot of mathematical operations, such as statistical analysis, cryptography, and simulations, can benefit significantly from JIT.
    2. Recursive algorithms: Recursive algorithms, such as the Fibonacci sequence, can benefit from JIT because JIT can optimize the code that is executed repeatedly.
    3. Loops: Applications that perform a lot of iteration, such as searching, sorting, and processing large datasets, can benefit from JIT.
    4. Dynamic code execution: Applications that generate and execute code dynamically, such as template engines and code generators, can benefit from JIT.
    It's important to note that the benefits of JIT will depend on the specific workload, and the performance improvement will not be the same for every application. However, JIT can provide a significant boost in performance for many PHP applications.