Closed ajhalls closed 3 years ago
Hi, I discovered this project just a few days ago and I thought it was a great idea and could benefit with performance.
But just learned the project is officially abandoned...
Besides, your tests show it actually does not improves performance too much...
You tested on PHP 7.2 while on the latest 7.4 it should be even faster.
Are you using Opcache or Preload in the test?
I didn't realize it was abandoned (https://www.reddit.com/r/PHP/comments/iogji4/zephir_will_not_be_maintained_any_longer_and_will/), thank you for letting me know. I wasn't using Opcache or Preload.
I know I can upgrade the PHP for additional performance, part of why I was building this into modules was to be able to whitelabel my application while maintaining some control over it through compiled obfuscation, the other was performance. Looking into other options.
Other options seem to be to build it in Rust and then use PHP FFI, or build a standalone API application server to handle those transformations for me. While I do a fair amount of .NET C# work, I haven't done much with C or C++ and feel that Rust may be more beneficial to learn if I have to learn something new. I realize PHP has a .NET option, but only if you run on a Windows server, which I will not likely ever do.
@cypherbits
But just learned the project is officially abandoned...
@ajhalls
I didn't realize it was abandoned
Zephir will not be maintained any longer and will not be compatible with PHP 8
I completely understand that we live in era of fake news, but on original news was written, quote: https://blog.phalcon.io/post/the-future-of-phalcon
Now that Serghei has stepped down, we have an issue with Zephir. We no longer have any active maintainers for the project to assume the lead and help with development/bugs etc.
and more important, quoute:
With no other options available, we will put active development of Zephir on hold, and we do not expect it to be compatible with PHP 8. Maintainers are always welcome to step up and help with Zephir.
@ajhalls
Now about performance diff only 10%. You won't gain any extra performance in loops and cycles like yours due array as char
and massive overhead, so you have near the same performance in PHP or in C. Single difference will be in memory usage, ~ x2 more in PHP.
I am looking to optimize my web API which receives a steady stream of medical data from hundreds of offices. As a proof of concept, I rewrote a portion of the API in Zephir to build the
Patient
object.The Zephir Code:
Our old way was:
I had stripped out a couple keys in the beginning of the test such as
'communication_id' => $user->office->communication_id
which wasn't part of the incoming data just to be simpler. So the Zephir one was doing about 3 less keys than the raw PHP per cycle.To test, I used the following:
The average times were: ~0.068428039550781 Seconds - Zephir ~0.076008081436157 Seconds - PHP
I have run the test a number of times and it seems Zephir gives me about a 10% boost, is that expected? Is there something more I should be doing to get better performance gains? Seems like I could almost get that just optimizing what I have a little more.
The tasks I was looking to move over would be string manipulations such as the PhoneOrNull, and those hit most often by the APIs. I am looking to optimize which processes are handling data to minimize calls to the database, so I would be passing in 2 objects, cross comparing values, and only sending updates to the database when records actually change.
Running on Ubuntu 18.04, PHP 7.2, Zephir 0.12.19