Add HHVM compile flag
As per this suggestion, compiling Phalcon would let it spread its wings in all PHP environments.
Some adjustments will be necessary, as per instructions on the comp layer's README, but it does seem possible.
In short - look into adding a flag to Zephir's compilation process to generate HHVM compatible code.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
good idea
This is very interesting! I think this is something that will have to been done eventually anyway. Unfortunately, I feel the adoption rate of HHVM is going to surpass the adoption rate of Phalcon, just because so many of the "cool kids" are pushing it now.
But this discussion does bring up one question that I have had for awhile now. Are the changes being made in PHPNG also being made in HHVM? Or have those or similar optimizations already been applied during the development of HHVM?
Whatever the answer to that question, which doesn't have a ton of relevance in this discussion directly, I think what @Swader has suggested, with adding a flag to optionally build HHVM compatible code, would be a great idea. It would indeed allow the end user the greatest amount of flexibility, no matter the PHP environment they found themselves working in.
I for one, after doing the testing I did with my blog, would be very interested to see if there were further performance improvements seen by Phalcon from running in HHVM. How cool would that be?
It would be crazy cool.
@phalcon if you ever do this, can you ping me beforehand so I can have an article pre-written for release time and we can do a major promotional push across all channels? I'd love to maybe even give readers a vagrant box which does this automatically, just vagrant up and you have HHVM powered Phalcon running.
Figured I would look into this, for giggles, but can already see this might take a little work in the current environment. Given the current listed requirements, it would break down a little like this...
- Use Z_RESVAL instead of Z_LVAL for resource access can be resolved by a simple Find-in-Project/Replace type of thing. Checked this in Sublime Text and looks pretty straight forward.
- Don't use PHP_MALIAS. Define the other function.
This looks like it will be where a bulk of the work would be and of course not something that I could resolve by myself. Of course, it could be as simple as performing a simple 'Find-in-Project' for the alias name and replacing it with the actual method name. Then removing the entries for the different instances of
PHP_MALIASExample:
PHP_MALIAS(Phalcon_Config, __get, offsetGet, arginfo___get, ZEND_ACC_PUBLIC)
_Here, the second parameter '__get' sets a new name to the existing method 'offsetGet' within the class 'Phalcon_Config'. We could then search for '_get' in the current class and return all uses of the offending alias. We then update each to use the actual method name instead of the aliased name, like so - From:
static PHP_METHOD(Phalcon_Registry, __get)
{
zval **property, **result;
// Rest of file removed due to this is an example
}
To:
static PHP_METHOD(Phalcon_Registry, offsetGet)
{
zval **property, **result;
//Rest of file removed due to this is an example
}
But looking through the different examples returned from the search, we cannot rely solely on a simple Find-Replace type of fix, due to there being different alias being assigned throughout the project in different classes. Yeah, this is were I am just a tad out of my league(given that the measurement of a 'tad' is around a football field or so).
- Change any ZVAL_STRING(foo, "literal string", 0) to ZVAL_STRING(foo, "literal string", 2) Searching the other library repos show that they are not following this, so... ???
- Allocate hashtables with ALLOC_HASHTABLE() and zvals with ALLOC_ZVAL() or one of the macros that calls ALLOC_ZVAL(), don't allocate them directly. Don't use malloc(sizeof(zval)) or create them on the stack.
There are only 4 instances of
malloc(sizeof(zval))in the project. But no idea how to go about resolving.
I'm closing this issue due to the lack of any reaction. I'll open it again if the need arises.