Theodicius

Good. Evil. Bratwurst.

How Code Imitates Chess

Posted on by arlen

or, How Google Got It Wrong.

Recently, Google announced how you should speed up your PHP. They got it wrong, virtually on every point. And not just by a little; subsequent testing showed one of their “improvements” actually resulted in code that took twice as long to execute!

How could this happen?

Maybe being a chessplayer gives me an advantage, but it’s obvious to me. It happens all the time in chess books. A grandmaster will analyse a chess position, and declare the best move is x! (The exclamation is required, it indicates an excellent move.) X! is therefore published to the world and Everyone Knows it’s the right move.

Everyone, that is, except the top chessplayers. Former World Champion Tigran Petrosian once wrote: “Oh, these exclamation marks! They are like a rust which corrodes the credulous soul of an amateur, depriving him of the critical approach to other’s judgments.”

But the real problem for chessplayers, is that even when a new approach is discovered, which renders x! harmless, New books will be published in which the old analysis is simply regurgitated onto the page. The advice to play x! is flawed, but repeated, because it once was published in a book.

How does that relate to Google? At one point in time, the tips they give were true. They did speed up code, under PHP3 or PHP4. But not now. The world has changed, and Google’s code suggestions failed to take that possibility into account.

Luckily, the response from the PHP team, complete with benchmarks, was fast enough that maybe the false information can be reigned back in. If you see the false information being repeated, feel free to use this post, the posts referenced here, or Sitepoint’s article to set the record straight.

Yes, if you’re running PHP4 and earlier Google’s tips might be useful, but can I suggest that if you’re still running PHP4 and earlier, maybe slow execution speed isn’t your biggest problem? PHP5 was released in July of 2004; support for PHP4 was dropped over a year ago, and no new security fixes will be released (the final one was August 2008). If your host requires you run PHP4, you’re far better off finding another host than wasting time with optimizations you’ll just have to undo when you finally do upgrade.

“As it was, so shall it ever be” is a guaranteed losing outlook for a chessplayer. Judgments and techniques change and improve over time; everything needs to be retested periodically lest it prove unreliable and let you down, just when you need it. Including Google.

Including me.

Leave a Reply

Your email address will not be published. Required fields are marked *

It sounds like SK2 has recently been updated on this blog. But not fully configured. You MUST visit Spam Karma's admin page at least once before letting it filter your comments (chaos may ensue otherwise).
June 2009
M T W T F S S
« May   Jul »
1234567
891011121314
15161718192021
22232425262728
2930