3 parts · Read in order

Reading the engine

How to get opcodes out of PHP, what the dispatch loop does with them, and what the optimizer changed before either happened.

  1. Two tools printed different opcodes for one function

    phpdbg showed thirteen instructions and the optimizer showed nine. Both were right. How to read the notation, and which listing is the one that runs.

    Part 18 min read

  2. The opcode is not the handler

    The same loop ran 23% faster with int parameters, and only with OPcache on. Operand classes pick a handler when the file compiles; proven types pick a different one.

    Part 28 min read

  3. OPcache's cache is not the part that made it faster

    The same function ran at 21.4 ns with no OPcache, 21.6 with OPcache and the optimizer off, and 14.8 with it on. What the passes removed, dumped one at a time.

    Part 37 min read

Arrow keys to move, Enter to open.