In a previous post titled "
The Spirit of Openness," Steven Grimm wrote about the various open source projects we use and contribute to at Facebook. We wanted to give everyone some "down and dirty" details on a couple of those projects, specifically relating to the
PHP community.
You might have noticed that the user-facing portion of Facebook is written in PHP, and we're fortunate enough to be able to make contributions back to some PHP related projects. Most of our contributions (so far) have been towards an optimization extension called the
Alternative PHP Cache (APC). Some of this code includes faster locking mechanisms like
Futex locks,
POSIX mutex locks, and porting
spin locks from the
PostgreSQL project. Some changes are bug fixes rather than enhancements, like bug
#7816 and #8663 (a configuration and file update bug which never really affected Facebook directly, but we're happy to help).
We've added
new caching statistics to help engineers learn what's being effectively cached and what's not. Our own
opcode copy optimizations significantly cut down Facebook load and response time last month. We also added
multi-key fetches,
faster statistics, and a cool
apc_compile_file function. We get to sneak in occasional patches to other PHP related projects like a PHP
foreach bug, a
"script" option for
xdebug, and PHP-5.2
compatibility for
APD. These changes cut down on the number of bugs engineers have to deal with, and give them new functionality for measuring site performance.
When site performance and technology is core to what you do, like it is at Facebook, having control over changes of every aspect of the site is crucial. Facebook runs with some modifications to projects like PHP that aren't stable or generic enough for inclusion in a public release (although we do our best to make these available). Having people available that work on programming languages, caches, or storage facilities gives Facebook a distinct edge over other sites that aren't as concerned about end user experience or being part of an open source community.
If you're interested in more information on open source projects, check out
ohloh.net. You can see statistics on
APC and
PHP as well as many other projects like
memcached, another project we are proud to contribute to. There are many people that come together to make these projects a reality, and it's awesome to be part of something that affects so many people. Getting involved in open source projects is a great way to learn and become part of a larger community. Finding a company that understands this as well is even better.
Brian Shire, an engineer at Facebook, is working on fixing some PHP bugs.