Optimizing APC for Multi-Core Systems

Location: D137
Average rating: ****.
(4.00, 1 rating)

When I started to work on PHP-APC, sometime in the ancient past of 2005,
most of the webservers were running on single processor systems, excluding
the odd Xeon SMP box. And consequently, with little thought for the future,
a large number of design decisions were made around the assumption that 2
cores were enough for any webserver. Overall it made life easier and nobody
got hurt. For a while, at least.

Enter present day, with the cloud slowly starting to listen at port 80 and
the megahertz wars slowly giving way to core-on-die wars. Behind the
scenes, very gently SMP systems are giving way to ccNUMA architectures
(Opteron, i7) which subtly change the performance characteristics of
what used to be a single flat address space. And more importantly, in the
forefront of all these, is the spectre of virtualization, which has
ensured no benchmark run is determinstic or repeatable.

And just like Goldilocks walking in late, what was “Just Right” half a decade
ago needs a trip to the microwave. Why? Because every bit of performance
matters. And it’s enlightening to look under the hood of the system and mostly
because this particular mess is one of my own. This is the story of that
self-aggravated catastrophe and how what used to be part of an High Performance Computing lecture
has turned into basic reading for regular server developers.

This talk goes into the guts of the opcode cache and the entire design of the
php interpreter, to pull out the code that can be run in parallel, with the
clever use of gcc atomic operation builtins, adding multiple locks & multiple
blocks of memory which would be “favoured” by a particular CPU for faster operations
and throwing out a few not so well thought out “optimizations”. Tackling other
villains like the interrupt ridden cpu0 and the cycle stealing monster that is
virtualization along the way, we end up with a php deployment ready for the
multi-core cloud. And for those who don’t actually use PHP, this is also a
shame basket of all my ideas which didn’t work.

Photo of Gopal Vijayaraghavan

Gopal Vijayaraghavan

Zynga Game Network, India

Gopal Vijayaraghavan is a principal engineer at Zynga and works out of their Bangalore office. He is part of the Systems Engineer Group, working towards improving PHP’s performance profile for Zynga games hosted on EC2. He is a lead developer of the open source PHP APC (alternative php cache). He hacks on PHP/APC as part of his work and otherwise. He is an avid photographer, biker and traveler, his photos can be found on flickr:http://flic.kr/t3rmin4t0r/ and his ramblings at his blog:http://notmysock.org/blog/.

Comments on this page are now closed.


Picture of Johannes Schlüter
Johannes Schlüter
07/29/2011 9:19pm PDT

Interesting talk, learned a few things :-)