Nikita Popov

PHP Performance Trivia by Nikita Popov

This talk discusses various issues of low-level PHP performance, such as: When is it more efficient to use arrays or objects? What causes catastrophic garbage collection? Does adding type annotations make PHP faster or slower?

I will answer these types of question with a (shallow) dive into PHP internals, touching on various topics like value representation, bytecode optimization and GC.

Talk Questions

  • Question 81
    Will JIT be ready for PHP 8?
  • Question 86
    What's better foreach/for or array_map, array_walk, array_filter ?
  • Question 17
    Compiled PHP on prod. There is currently a hack that employs opcache to precompile PHP. This makes sense on prod and we still reap runtime benefits in dev. Could a robust solution exist in the future and solve type issues,
  • Question 93
    Iterable vs array return, which is better for oppcache optimization?
  • Question 80
    What do you think about the performance gained using having in mind that php was meant to die and a php server is not "encouraged"?
  • Question 83
    Does preloading yied a smaller or a larger benefit with shallower class hierarchies when compared to deep class hierarchcies?
  • Question 87
    What is the most optimal way of looping (foreach?) through an array with objects?
  • Question 94
    Do we get all Opcache optimizations if we use file_cache_only?
  • Question 95
    Are final classes faster?
  • Question 82
    Will be the internal ast of a php file exposed to userland? Not only token_get_all
  • Question 84
    Can you use two Op Code SHM to avoid downtime?
  • Question 92
    Haskell optimizes for immutability, can they do that because it is compiled or can their technique be used in php?
  • Question 85
    Do you recommend using ArrayIterator instead of simple arrays?
  • Question 88
    Can we have array_{map,reduc,etc} with iterable instead of array as parameter?
  • Question 89
    Hack has generics, how is their performance?
  • Question 90
    Ok type declaration is compute cost extensive but could we have a flag in the configuration that would enable extensive use of types? It will let us choose between speed and type security.
  • Question 91
    Could the number of check the runtime does be configuarable? E.g. I want to enable type hinting and but someone else wants to turn it off.
  • Question 98
    Why lambda does not support pho?
  • Question 100
    I guess they meant Haskell's TCO
  • Question 122
    I meant . We're using immutable sets (enforced by ourselves) but large sets become to slow to use.