PHP’s new hashtable implementation

/PHPs-new-hashtable-implementation.html

  • PHP7’s new hashtable implementation
    http://nikic.github.io/2014/12/22/PHPs-new-hashtable-implementation.html

    About three years ago I wrote an article analyzing the memory usage of arrays in PHP 5. As part of the work on the upcoming PHP 7, large parts of the Zend Engine have been rewritten with a focus on smaller data structures requiring fewer allocations. In this article I will provide an overview of the new hashtable implementation and show why it is more efficient than the previous implementation.

    To measure memory utilization I am using the following script, which tests the creation of an array with 100000 distinct integers:

    $startMemory = memory_get_usage(); $array = range(1, 100000); echo memory_get_usage() - $startMemory, “bytes\n”;

    The following table shows the results using PHP 5.6 and PHP 7 on 32bit and 64bit systems:

    | 32 bit | 64 bit

    PHP 5.6 | 7.37 MiB | 13.97 (...)