nikic / buffer

PHP extension for buffer based typed arrays
Other
42 stars 5 forks source link

Question related to the PHP engine and ArrayBuffers #2

Open frodeborli opened 2 years ago

frodeborli commented 2 years ago

Hi; you don’t know me but I would like to say that it was a sad thing for the PHP community to learn that you moved over to LLVM; but I hope you are doing well. Over to my question:

I learned today some background from the PHP internals and the process leading up to PHP version 7, and also the JIT feature in 7.4:

That PHP’s JIT performance suffers because of extra CPU cache misses when JIT is enabled. Based on this, Dmitri did some great work on optimizing the memory requirements for important data structures in PHP 7.

This reduced the memory requirements of PHP and contributed to a ca 200% performance increase for PHP - mostly attributed to reduced memory bandwidth needs.

Question: Can an extension like this ever hope to compete in performance, compared to a native op-code based approach to implementing array buffers? If so; I will consider adopting it into an RFC for PHP.

(Also because I am curious, but irrelevant for this extension; but I know you have an opinion: Could potentially re-implementing for example most of the \str* functions as pure PHP - reduce the amount of CPU cache space needed and lead to a faster language in general?)