Scripts run faster with mmcache disabled

  • Michael Reynolds

    For my testing, I used the following PHP code:
    for($r=0,$i=0;$i<=100000;$i++) { $r.=md5($i); }

    With mmcache's caching and optimizations enabled, ab gives the following:
    Requests per second:    0.19 [#/sec] (mean)
    Time per request:       5136.266 [ms] (mean)

    ...and with mmcache disabled:
    Requests per second:    0.20 [#/sec] (mean)
    Time per request:       5035.509 [ms] (mean)

    Each was run with 200 requests.  There's not a large speed difference, but it is faster without the use of mmcache.

    • Michael Reynolds

      Oops, forgot mmcache_cache_page($PHP_SELF."?GET=".serialize($_GET));

      But using that caches the output of the PHP script, which is undesired behavior.

    • David

      David - 2003-10-17

      MMCache is a opcode cacher, meaning if you have 500lines of codes, it will skips the overhead of compiling the code before execution

      MD5 is MD5, how can it be optimized?? Especialy in such loop...

      • Ilia Alshanetsky

        The cache itself could do very little to make such a script faster. However, the optimizer could do quite a bit. In this particular case, the optimizer can see that the loop is working on a static limit and unroll the loop. More over, since the argument is 'predictable', the function call can be replaced with internal C function for generating md5s.

    • Dmitry Stogov

      Dmitry Stogov - 2003-10-17

      MMCache don't  try to do global optimization and invarioant code motion, but I think this code can't be optimized at all.

      In my case the code run a litel bit faster with MMCache enabled (I do "ab" testing from another computer).

    • Robert Coyne

      Robert Coyne - 2003-10-18

      Okay, let's try another example. I have 2486 lines of "code" in my user system right now. I've used MMCache as both a Zend extension and a PHP extension. Neither way provided any drastic speed improvement over vanilla PHP. Without MMCache PHP can generate most pages in ~0.0070-0.0800ms. With MMCache enable this drops to ~0.054-0.0700ms.

      I fail to see the real advantage of using MMCache. Am I missing somthing? Not to mention the fact that even though the generation times are indeed somewhat faster, in reality they still seem slower.

    • TiM

      TiM - 2003-10-22

      Well, I'm not sure what your using, but I see the following performance improvements using mmcache.

      With MMCache:
      Requests per second:    3.25 [#/sec] (mean)
      Time per request:       1540.829 [ms] (mean)
      Time per request:       308.166 [ms] (mean, across all concurrent requests)
      Transfer rate:          69.57 [Kbytes/sec] received

      Without MMCache:
      Requests per second:    1.93 [#/sec] (mean)
      Time per request:       2590.160 [ms] (mean)
      Time per request:       518.032 [ms] (mean, across all concurrent requests)
      Transfer rate:          41.40 [Kbytes/sec] received

      So I'm certainly seeing a good improvement.  That code I'm testing is very DB dependant too, I suspect if I was testing code that wasn't tied to the DB then I'd see a much large performance increase.


    • Robert Hostetter

      This is because mmcache lowers loading times.  The script will probably run NO faster other than that in my experience.  However this does make things run visibly faster.

    • Mark Dickenson

      Mark Dickenson - 2004-04-21

      We run a web based game that is fairly popular.  We have 3 games running on one server and it is very database intensive.

      Without MMCache installed our server load was running 500-700% with the three games half full of players.  This was causing massive amounts of lag in the game.

      We installed MMCache with encoding and caching enabled.  Our server loaded dropped to 20-50% with a similar number of people online in all three games.

      This was a MASSIVE increase in speed and lowering of the server load.  If you are running simple things people are talking about above you will not notice any substantive increase in speed.  You need to have a server that has substantial activity to notice any speed increases and drops in server load.

      MMCache is a MUST HAVE for any site that gets average to high activity.


Log in to post a comment.