One of the key values at Facebook is to move fast. For the past six years, we have been able to accomplish a lot thanks to rapid pace of development that PHP offers. As a programming language, PHP is simple. Simple to learn, simple to write, simple to read, and simple to debug. We are able to get new engineers ramped up at Facebook a lot faster with PHP than with other languages, which allows us to innovate faster.
Today I'm excited to share the project a small team of amazing people and I have been working on for the past two years; HipHop for PHP. With HipHop we've reduced the CPU usage on our Web servers on average by about fifty percent, depending on the page. Less CPU means fewer servers, which means less overhead. This project has had a tremendous impact on Facebook. We feel the Web at large can benefit from HipHop, so we are releasing it as open source this evening in hope that it brings a new focus toward scaling large complex websites with PHP. While HipHop has shown us incredible results, it's certainly not complete and you should be comfortable with beta software before trying it out.
HipHop for PHP isn't technically a compiler itself. Rather it is a source code transformer. HipHop programmatically transforms your PHP source code into highly optimized C++ and then uses g++ to compile it. HipHop executes the source code in a semantically equivalent manner and sacrifices some rarely used features — such as eval() — in exchange for improved performance. HipHop includes a code transformer, a reimplementation of PHP's runtime system, and a rewrite of many common PHP Extensions to take advantage of these performance optimizations.
Scaling PHP as a Scripting Language
PHP's roots are those of a scripting language, like Perl, Python, and Ruby, all of which have major benefits in terms of programmer productivity and the ability to iterate quickly on products. This is compared to more traditional compiled languages like C++ and interpreted languages like Java. On the other hand, scripting languages are known to generally be less efficient when it comes to CPU and memory usage. Because of this, it's been challenging to scale Facebook to over 400 billion PHP-based page views every month.
One common way to address these inefficiencies is to rewrite the more complex parts of your PHP application directly in C++ as PHP Extensions. This largely transforms PHP into a glue language between your front end HTML and application logic in C++. From a technical perspective this works well, but drastically reduces the number of engineers who are able to work on your entire application. Learning C++ is only the first step to writing PHP Extensions, the second is understanding the Zend APIs. Given that our engineering team is relatively small — there are over one million users to every engineer — we can't afford to make parts of our codebase less accessible than others.
Scaling Facebook is particularly challenging because almost every page view is a logged-in user with a customized experience. When you view your home page we need to look up all of your friends, query their most relevant updates (from a custom service we've built called Multifeed), filter the results based on your privacy settings, then fill out the stories with comments, photos, likes, and all the rich data that people love about Facebook. All of this in just under a second. HipHop allows us to write the logic that does the final page assembly in PHP and iterate it quickly while relying on custom back-end services in C++, Erlang, Java, or Python to service the News Feed, search, Chat, and other core parts of the site.
Since 2007 we've thought about a few different ways to solve these problems and have even tried implementing a few of them. The common suggestion is to just rewrite Facebook in another language, but given the complexity and speed of development of the site this would take some time to accomplish. We've rewritten aspects of the Zend Engine — PHP's internals — and contributed those patches back into the PHP project, but ultimately haven't seen the sort of performance increases that are needed. HipHop's benefits are nearly transparent to our development speed.
Hacking Up HipHop
One night at a Hackathon a few years ago (see Prime Time Hack), I started my first piece of code transforming PHP into C++. The languages are fairly similar syntactically and C++ drastically outperforms PHP when it comes to both CPU and memory usage. Even PHP itself is written in C. We knew that it was impossible to successfully rewrite an entire codebase of this size by hand, but wondered what would happen if we built a system to do it programmatically.
Finding new ways to improve PHP performance isn't a new concept. At run time the Zend Engine turns your PHP source into opcodes which are then run through the Zend Virtual Machine. Open source projects such as APC and eAccelerator cache this output and are used by the majority of PHP powered websites. There's also Zend Server, a commercial product which makes PHP faster via opcode optimization and caching. Instead, we were thinking about transforming PHP source directly into C++ which can then be turned into native machine code. Even compiling PHP isn't a new idea, open source projects like Roadsend and phc compile PHP to C, Quercus compiles PHP to Java, and Phalanger compiles PHP to .Net.
Needless to say, it took longer than that single Hackathon. Eight months later, I had enough code to demonstrate it is indeed possible to run faster with compiled code. We quickly added Iain Proctor and Minghui Yang to the team to speed up the pace of the project. We spent the next ten months finishing up all the coding and the following six months testing on production servers. We are proud to say that at this point, we are serving over 90% of our Web traffic using HipHop, all only six months after deployment.
How HipHop Works
The main challenge of the project was bridging the gap between PHP and C++. PHP is a scripting language with dynamic, weak typing. C++ is a compiled language with static typing. While PHP allows you to write magical dynamic features, most PHP is relatively straightforward. It's more likely that you see if (...) {...} else {..} than it is to see function foo($x) { include $x; }. This is where we gain in performance. Whenever possible our generated code uses static binding for functions and variables. We also use type inference to pick the most specific type possible for our variables and thus save memory.
The transformation process includes three main steps:
Static analysis where we collect information on who declares what and dependencies,
Type inference where we choose the most specific type between C++ scalars, String, Array, classes, Object, and Variant, and
Code generation which for the most part is a direct correspondence from PHP statements and expressions to C++ statements and expressions.
We have also developed HPHPi, which is an experimental interpreter designed for development. When using HPHPi you don't need to compile your PHP source code before running it. It's helped us catch bugs in HipHop itself and provides engineers a way to use HipHop without changing how they write PHP.
Overall HipHop allows us to keep the best aspects of PHP while taking advantage of the performance benefits of C++. In total, we have written over 300,000 lines of code and more than 5,000 unit tests. All of this will be released this evening on GitHub under the open source PHP license.
Learn More this Evening
This evening we're hosting a small group of developers to dive deeper into HipHop for PHP and will be streaming this tech talk live. Check back here around 7:30pm Pacific time if you'd like to watch.
As I'm sure there will be plenty of questions, starting this evening take a look at the HipHop wiki or join the HipHop developer mailing list. You'll also find us at FOSDEM, SCALE, PHP UK, ConFoo, TEK X, and OSCON over the next few months talking about HipHop for PHP. We're very excited to evolve HipHop into a thriving open source project along with all of you.

Facebook是一个全球知名的社交媒体平台,它为用户提供了一个连接和交流的平台。成立于2004年,由马克·扎克伯格等人创建。它是一个在线社交网络,用户可以在上面与朋友、家人和同事分享信息、照片和视频,并与他们进行互动,它的影响力不仅限于个人用户,还扩展到了企业和新闻领域。

facebook的意思是一个美国的互联网公司,也指的是该公司开发的社交网络服务网站;facebook创立于2004年2月4日,是一款世界著名的社交通讯类应用,用户能够使用这款应用与世界各地的人们进行交流。

近期,作者发现了Facebook安卓APP应用的一个深度链接漏洞,利用该漏洞,可以把用户手机上安装的Facebook安卓APP应用转变成后门程序(Backdoor),实现后门化。另外,利用该漏洞还可以重打包FacebookAPP,并将其发送给特定目标受害者安装使用。下面就来看看作者对该漏洞的发现过程,以及如何通过Payload构造,最终将其转化为FacebookAPP实际生产环境中的安全隐患。漏洞发现通常做众测时,我会先认真了解目标系统的应用机制。在我的上一篇博客中,我已经分享了通过解析Face

正文Facebook嵌入式视频播放器API是JavaScript版FacebookSDK提供的客户端功能。可以在自己网站上播放Facebook视频。开始使用先引入FacebookSDK封装成组件FacebookPlayerimport{onMounted,onBeforeUnmount}from"vue";constprops=defineProps({id:{type:String,default:""},src:{type:String,require

当尝试在浏览器中使用Facebook Messenger进行视频通话时,有时会抱怨硬件访问错误。弹出错误,说“您需要允许在PC上进行视频通话的麦克风和摄像头访问”。这可能是因为您可能希望在计算机上启用摄像头和麦克风访问,或者因为过时的驱动程序、冲突的设备、站点权限问题等。在本文中,我们有不同的解决方案来解决此错误。让我们开始吧!方法 1:允许桌面应用访问你的相机和麦克风步骤1:使用Windows + I键一起打开Windows设置第 2 步:点击隐私第三步: 在左侧,向下滚动并单击麦克风步骤4:

用for求n阶乘的方法:1、使用“for (var i=1;i<=n;i++){}”语句控制循环遍历范围为“1~n”;2、循环体中,使用“cj*=i”将1到n的数相乘,乘积赋值给变量cj;3、循环结束后,变量cj的值就n的阶乘,输出即可。

什么是AMP币?AMP代币是由Synereo团队于2015年创立,作为Synereo平台的主要交易货币。AMP代币旨在通过多种功能和用途,为用户提供更好的数字经济体验。AMP代币的用途AMP代币在Synereo平台中拥有多重角色和功能。首先,作为平台的加密货币奖励系统的一部分,用户能够通过分享和推广内容来获得AMP奖励,这一机制鼓励用户更积极地参与平台的活动。AMP代币还可用于在Synereo平台上推广和传播内容。用户可以通过使用AMP代币提升他们的内容在平台上的曝光率,以吸引更多观众来查看和分

facebook的canvas优势有高度可定制、强大的功能、良好的性能、跨平台兼容性、丰富的生态系统等等。详细介绍:1、高度可定制,Facebook Canvas允许开发人员完全自定义应用程序的外观和行为,包括界面、导航栏、状态栏等;2、强大的功能,Facebook Canvas提供了许多内置功能,如访问Facebook用户数据、使用Facebook登录、分享内容等等。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Dreamweaver CS6
Visual web development tools

SublimeText3 Chinese version
Chinese version, very easy to use

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.
