Function call speedup (CV applied to functions)

From: Date: Mon, 04 Dec 2006 05:48:44 +0000
Subject: Function call speedup (CV applied to functions)
Groups: php.internals 
Request: Send a blank email to internals+get-26782@lists.php.net to get a copy of this message
It's been a concept stuck in my mind since I first looked into ZE2.1 and saw what compiled variables were, and a recent blog post (http://php100.wordpress.com/2006/11/24/optimizations/) (which got picked up by planet PHP) got my wheels spinning again. Tonight I decided to actually sit down and see what benefit could be milked from such an endeavor and what it's maintenance cost would be. The attached patch shows what I've tossed together for HEAD and the benchmark I've run against it do show some appreciable gains... Based on this code snippet, I saw a consistent gain of aproximately 18%: for($i = 0; $i < 10000000; $i++) pi(); I chose the pi() function as it (A) would actually favor the unpatched approach, being quick to hash and strcmp. It also (B) performs minimal actual work, simply returning a constant value, thus leaving as much of the execution time to the matter being tested as possible. Of course, this isn't a "normal use" example, and it doesn't address dynamic function calls or method calls. I also havn't looked into class resolution yet, but this is a good spot to begin discussion from. Thoughts anyone? -Sara

« previous php.internals (#26782) next »