rfc:remove_zend_api

This is an old revision of the document!


Remove reliance on Zend API

A better way to provide a C API, with particular emphasis on decoupling extensions from the interpreter.

Introduction

Naturally, this seems insane. Please bear with me.

What's the problem?

Zend API

The Zend API is a large set of functions, macros and data-structures which are used to interact with the Zend Engine. It serves 3 major purposes, roughly in order of importance:

  • Used to write PHP's standard libraries, 3rd party extensions, and much of PECL
  • Allows hot (performance-sensitive) code to be rewritten in C for speed
  • Used to embed PHP into within C/C++ applications using the embed SAPI

Problems

The main problem with it is that it constrains the implementation of the Zend Engine. By requiring backwards compatability with the Zend Engine, we are ensuring that the ZendEngine can only be modified in minor ways, which must be mostly backward compatible (ABI changes are allowed for major versions, like PHP 6). This inhibits large improvements to the Zend Engine. It is instead held to design decisions made nearly 10 years ago. This will prevent PHP from getting much faster in the long term.

The Zend API also makes it difficult to write PHP extensions. Although most of the API is not terribly difficult to work with, concepts like copy-on-write, change-on-write sets and separation appear to be tricky concepts for many people. The only documentation is Sara Golemon's book, and the actual code is not well commented.

A number of other PHP implementations exist, such as IBM's Project Zero, Phalanger, Roadsend, Quercus and phc. Many of these projects find it very difficult to re-use PHP's standard libraries. Quercus and Roadsend have reimplemented popular standard libraries. Phalanger and Project Zero attempt to re-use the existing libraries by marshalling their data into the Zend API. This appears to be slow and error-prone. phc is designed around reusing the Zend API for compatibility with the PHP. This constrains many of the speed improvements we'd like to do, since we need to use the Zend API nearly everywhere.

What's the solution?

Project Plan

Changelog

rfc/remove_zend_api.1238244216.txt.gz · Last modified: 2017/09/22 13:28 (external edit)