Welcome to Centmin Mod Community
Become a Member

PHP-FPM PHP Redis, no igbinary as available serializers?

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by rdan, Mar 29, 2023.

  1. rdan

    rdan Well-Known Member

    5,439
    1,396
    113
    May 25, 2014
    Ratings:
    +2,185
    Local Time:
    5:26 PM
    Mainline
    10.2
    • CentOS Version: CentOS 7 64bit
    • Centmin Mod Version Installed: 124.00stable
    • PHP Version Installed: 8.0.28
    upload_2023-3-29_15-56-16.png


    But it is installed.
    upload_2023-3-29_15-55-31.png
     
  2. rdan

    rdan Well-Known Member

    5,439
    1,396
    113
    May 25, 2014
    Ratings:
    +2,185
    Local Time:
    5:26 PM
    Mainline
    10.2
    On my Ubuntu server, it is listed:
    upload_2023-3-29_15-57-16.png
     
  3. eva2000

    eva2000 Administrator Staff Member

    52,787
    12,080
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,607
    Local Time:
    7:26 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    What output do you get for command
    Code (Text):
    php -i | grep php_serialize

    for PHP 8.2.4 I see
    Code (Text):
    php -i | grep php_serialize
    Registered serializer handlers => php_serialize php php_binary igbinary 
    
     
  4. eva2000

    eva2000 Administrator Staff Member

    52,787
    12,080
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,607
    Local Time:
    7:26 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    FYI, not much a benefit though as igbinary serializer is no longer fastest. The default PHP serializer is fastest anyway see benchmark

    php-serializer-benchmark.php
    PHP:
    <?php
    // Generate a larger data set with 100000 entries
    $data = [];
    for (
    $i 0$i 100000$i++) {
      
    $data[] = [
        
    'name' => 'Person ' . ($i 1),
        
    'age' => rand(1860),
        
    'city' => 'City ' rand(110),
        
    'hobbies' => ['reading''writing''coding']
      ];
    }

    // Default PHP serializer
    $start microtime(true);
    $serialized serialize($data);
    $time microtime(true) - $start;
    echo 
    "Default serializer: {$time}\n";

    // JSON serializer
    $start microtime(true);
    $serialized json_encode($data);
    $time microtime(true) - $start;
    echo 
    "JSON serializer: {$time}\n";

    // igbinary serializer
    $start microtime(true);
    $serialized igbinary_serialize($data);
    $time microtime(true) - $start;
    echo 
    "igbinary serializer: {$time}\n";
    Code (Text):
    php -f php-serializer-benchmark.php
    
    Default serializer: 0.028717041015625
    JSON serializer: 0.025160074234009
    igbinary serializer: 0.053094863891602
    
     
  5. eva2000

    eva2000 Administrator Staff Member

    52,787
    12,080
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,607
    Local Time:
    7:26 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    though deserializeation igbinary wins which is probably where it's strengths are
    php-deserializer-benchmark.php
    PHP:
    <?php
    // Generate a larger data set with 100000 entries
    $data = [];
    for (
    $i 0$i 100000$i++) {
      
    $data[] = [
        
    'name' => 'Person ' . ($i 1),
        
    'age' => rand(1860),
        
    'city' => 'City ' rand(110),
        
    'hobbies' => ['reading''writing''coding']
      ];
    }

    // Serialize the data set with each serializer
    $serialized_default serialize($data);
    $serialized_json json_encode($data);
    $serialized_igbinary igbinary_serialize($data);

    // Deserialization tests
    $start microtime(true);
    $deserialized unserialize($serialized_default);
    $time microtime(true) - $start;
    echo 
    "Default deserializer: {$time}\n";

    $start microtime(true);
    $deserialized json_decode($serialized_jsontrue);
    $time microtime(true) - $start;
    echo 
    "JSON deserializer: {$time}\n";

    $start microtime(true);
    $deserialized igbinary_unserialize($serialized_igbinary);
    $time microtime(true) - $start;
    echo 
    "igbinary deserializer: {$time}\n";
    Code (Text):
    php -f php-deserializer-benchmark.php 
    Default deserializer: 0.05321192741394
    JSON deserializer: 0.08840012550354
    igbinary deserializer: 0.022739887237549
    
     
  6. eva2000

    eva2000 Administrator Staff Member

    52,787
    12,080
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,607
    Local Time:
    7:26 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    combined benchmark :)

    php-serialize-benchmark.php
    PHP:
    <?php
    // Generate a larger data set with 50000 entries
    $data = [];
    for (
    $i 0$i 50000$i++) {
      
    $data[] = [
        
    'name' => 'Person ' . ($i 1),
        
    'age' => rand(1860),
        
    'city' => 'City ' rand(110),
        
    'hobbies' => ['reading''writing''coding']
      ];
    }

    // Serializer benchmarks
    $start microtime(true);
    $serialized_default serialize($data);
    $time_serial_default microtime(true) - $start;

    $start microtime(true);
    $serialized_json json_encode($data);
    $time_serial_json microtime(true) - $start;

    $start microtime(true);
    $serialized_igbinary igbinary_serialize($data);
    $time_serial_igbinary microtime(true) - $start;

    // Deserializer benchmarks
    $start microtime(true);
    $deserialized_default unserialize($serialized_default);
    $time_deserial_default microtime(true) - $start;

    $start microtime(true);
    $deserialized_json json_decode($serialized_jsontrue);
    $time_deserial_json microtime(true) - $start;

    $start microtime(true);
    $deserialized_igbinary igbinary_unserialize($serialized_igbinary);
    $time_deserial_igbinary microtime(true) - $start;

    // Combined benchmarks
    $start microtime(true);
    $serialized_deserialized_default unserialize(serialize($data));
    $time_combined_default microtime(true) - $start;

    $start microtime(true);
    $serialized_deserialized_json json_decode(json_encode($data), true);
    $time_combined_json microtime(true) - $start;

    $start microtime(true);
    $serialized_deserialized_igbinary igbinary_unserialize(igbinary_serialize($data));
    $time_combined_igbinary microtime(true) - $start;

    // Report results
    echo "Default serializer time: {$time_serial_default}\n";
    echo 
    "Default deserializer time: {$time_deserial_default}\n";
    echo 
    "Default combined time: {$time_combined_default}\n\n";

    echo 
    "JSON serializer time: {$time_serial_json}\n";
    echo 
    "JSON deserializer time: {$time_deserial_json}\n";
    echo 
    "JSON combined time: {$time_combined_json}\n\n";

    echo 
    "igbinary serializer time: {$time_serial_igbinary}\n";
    echo 
    "igbinary deserializer time: {$time_deserial_igbinary}\n";
    echo 
    "igbinary combined time: {$time_combined_igbinary}\n";
     
  7. rdan

    rdan Well-Known Member

    5,439
    1,396
    113
    May 25, 2014
    Ratings:
    +2,185
    Local Time:
    5:26 PM
    Mainline
    10.2
    Code:
    Registered serializer handlers => php_serialize php php_binary igbinary
    
     
  8. eva2000

    eva2000 Administrator Staff Member

    52,787
    12,080
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,607
    Local Time:
    7:26 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    IIRC, PHP 8+ has native igbinary support so doesn't need an external igbinary extension for it that's why. You can confirm this running the benchmark scripts above on your PHP 8+ installs that don't show igbinary in PHPINFO
     
  9. eva2000

    eva2000 Administrator Staff Member

    52,787
    12,080
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,607
    Local Time:
    7:26 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Re-reading that you are missing igbinary serializer support for redis extension and no PHP itself. My above comments are for PHP itself and native igbinary support. But same end result, igbinary as a serializer is slower than default PHP 8.x so letting redis extension use default PHP serializer will be faster than igbinary. So no need for igbinary as a redis serializer.
     
  10. rdan

    rdan Well-Known Member

    5,439
    1,396
    113
    May 25, 2014
    Ratings:
    +2,185
    Local Time:
    5:26 PM
    Mainline
    10.2
    So I think it's okay to have igbinary disabled by default now?
     
  11. eva2000

    eva2000 Administrator Staff Member

    52,787
    12,080
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,607
    Local Time:
    7:26 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    enabled natively by PHP 8 support so no real need to disable it, it's only used if you code PHP scripts to use igbinary