[RFC|Accepted] HipHop for PHP compatibility

Note: We are moving the topics of this forum and it will be deleted at some point

Publish your own request for comments/change or patches for the next version of phpBB. Discuss the contributions and proposals of others. Upcoming releases are 3.2/Rhea and 3.3.
Post Reply
ckwalsh
Registered User
Posts: 54
Joined: Tue Apr 18, 2006 2:25 am

[RFC|Accepted] HipHop for PHP compatibility

Post by ckwalsh » Sat Jan 08, 2011 1:03 am

the HipHop wiki on Github wrote:HipHop for PHP transforms PHP source code into highly optimized C++. It was developed by Facebook and was released as open source in early 2010.

HipHop transforms your PHP source code into highly optimized C++ and then compiles it with g++ to build binary files. You keep coding in simpler PHP, then HipHop executes your source code in a semantically equivalent manner and sacrifices some rarely used features – such as eval() – in exchange for improved performance.
It seems advantageous to have phpBB compatible with HipHop for the benefit of large boards, as it is much more efficient and less memory intensive than a standard installation, as well as being more secure (php code injection is quite literally impossible). Additionally, due to the limitations of the HipHop platform, compatibility will force the removal of php language features (primarily eval() based logic) from the phpBB codebase, resulting in cleaner code.

I have already prepared a patch for such compatibility, and have confirmed it functions in both a php and hphp environment. The tree can be found at https://github.com/ckwalsh/phpbb3/tree/ ... lsh/hiphop. To build phpBB with HipHop, compile HipHop per their wiki instructions, execute the ./develop/hiphop.php script in my branch, and follow the instructions.

As a side note, As of this posting HipHop has a bug that prevents templates from outputting correctly. I have fixed this in my own HipHop branch, and it has not been merged into the main repository. Until it is fixed, use my HipHop repository instead of the official one to build hphp and phpBB3.

Oleg
Posts: 1150
Joined: Tue Feb 23, 2010 2:38 am
Contact:

Re: [RFC|Accepted] HipHop for PHP compatibility

Post by Oleg » Sat Jan 08, 2011 2:24 am

I do not necessarily object to the contents of this rfc, but should this post not be in the 3.2 forum?
Rules said:

All features which do not have an implementation at that point, will be postponed to 3.2.

User avatar
naderman
Product Manager
Product Manager
Posts: 1727
Joined: Sun Jan 11, 2004 2:11 am
Location: Karlsruhe, Germany
Contact:

Re: [RFC|Accepted] HipHop for PHP compatibility

Post by naderman » Sat Jan 08, 2011 3:15 am

No this is a direct consequence of the coding guideline changes in 3.1 which no longer allow the use of eval. But instead of just discussing this on IRC/the tracker we asked Cullen to post this as a late RFC just so it can be better discussed.

Oleg
Posts: 1150
Joined: Tue Feb 23, 2010 2:38 am
Contact:

Re: [RFC|Accepted] HipHop for PHP compatibility

Post by Oleg » Sat Jan 08, 2011 5:38 am

I see. I reviewed the diff again and I do have some comments/suggestions.

1. The warnings about unsuitability for production use and dangerousness - why is the script unsuitable for production use and dangerous? Considering that hiphop typically is used in production environments, some more guidance will probably be welcome.

2. I personally will take issue with one aspect of the hiphop.php script not being suitable for production, and that is compiling templates to php files. It is something I want to do during deployment (as opposed to on demand) and as such a feature I find very suitable for production. It would be great if the code to compile templates was placed into a function that was itself part of the phpbb distribution. A separate file perhaps if you don't want to bloat existing files? But then if it is used the regular on demand compilation will never be needed.

3. Why is mysql required? Is it the only database engine supported by hiphop? An explanation would be appreciated.

4. I dislike gratuitous use of eval as much as the next guy, but replacing one line of eval with two pages of php code is a tough decision, especially if the two pages are known to run slower. (Much slower?) What about keeping both versions around and using the eval version if eval is available? Is eval undefined under hiphop? Hopefully there is a way of detecting whether eval is functional.

ckwalsh
Registered User
Posts: 54
Joined: Tue Apr 18, 2006 2:25 am

Re: [RFC|Accepted] HipHop for PHP compatibility

Post by ckwalsh » Sat Jan 08, 2011 7:46 am

nn- wrote:I see. I reviewed the diff again and I do have some comments/suggestions.

1. The warnings about unsuitability for production use and dangerousness - why is the script unsuitable for production use and dangerous? Considering that hiphop typically is used in production environments, some more guidance will probably be welcome.
I worded that poorly. The script should not be accessible to the outside world (and really none of the scripts in the develop folder should). It should be used for setting up hiphop, but not compiled in nor made available via apache.
nn- wrote:2. I personally will take issue with one aspect of the hiphop.php script not being suitable for production, and that is compiling templates to php files. It is something I want to do during deployment (as opposed to on demand) and as such a feature I find very suitable for production. It would be great if the code to compile templates was placed into a function that was itself part of the phpbb distribution. A separate file perhaps if you don't want to bloat existing files? But then if it is used the regular on demand compilation will never be needed.
In a HipHop environment, on demand compilation is impossible. As I clarified with #1, the script should be run to prepare the files for c++ compilation. As for why it is in the develop folder, it is an advanced feature that I'll admit, most boards won't take advantage of. Those wanting to take advantage of it likely will have no problem installing phpBB using the git repository, where it is available. The only other considerable options are docs and install, and neither seem appropriate.
nn- wrote:3. Why is mysql required? Is it the only database engine supported by hiphop? An explanation would be appreciated.
HipHop only supports the mysql interface, not mysqli. Since they reimplemented almost everything for HipHop, I'm sure it doesn't suffer some of the drawbacks php's mysql extension does that people switched to mysql for.
nn- wrote:4. I dislike gratuitous use of eval as much as the next guy, but replacing one line of eval with two pages of php code is a tough decision, especially if the two pages are known to run slower. (Much slower?) What about keeping both versions around and using the eval version if eval is available? Is eval undefined under hiphop? Hopefully there is a way of detecting whether eval is functional.
I can't think of a good way to detect it without adding a "IS_HIPHOP" definition, which seems like an incredibly bad idea. While I'll admit it is slower, the parse time is insignificant compared to the costs of mysql queries, output generation, and other factors that slow down a page. Additionally, since it will only be run once each page load, it's not a huge cost.


TerryE
Registered User
Posts: 95
Joined: Sat May 23, 2009 12:24 am
Contact:

Re: [RFC|Accepted] HipHop for PHP compatibility

Post by TerryE » Tue Apr 05, 2011 8:29 pm

I've added a few lines of audit to my OOo forums so I collect the microtimes between session start and both the entry to page_header and the return from page_footer. There are very few apps lines before this (mostly compiling and loading which won't be there in an HipHop environent), and these measures give a good idea of the actual time spent in the apps code and template presentation.

For viewtopic (which is about 70% of all requests) these figures average at 31 mSec and 42 mSec respectively. Of this about 20mSec is MySQL queries, so the PHP interpeter time is ~10 and 20 mSec. Using HipHop will halve this reducing these by about 5 mSec and 10 mSec.

If I take the phpBB community forums as an example the total response time for a viewforum is 1-2 secs. In otherwords using HipHop would shave off less than 1% of this.

HipHop is a brilliant idea where PHP is being used for algorithmicly intensive processsing -- building Facebook walls and Wiki pages using complex templates are maybe a good example, but phpBB ??? This might be a fun exercise, but why an accepted RFC for 3.1?

User avatar
naderman
Product Manager
Product Manager
Posts: 1727
Joined: Sun Jan 11, 2004 2:11 am
Location: Karlsruhe, Germany
Contact:

Re: [RFC|Accepted] HipHop for PHP compatibility

Post by naderman » Wed Apr 06, 2011 12:48 am

Solely because the necessary changes like getting rid of eval have other benefits than HipHop compatability. HipHop is as you pointed out not a relevant target for phpBB.

Post Reply