Component cache overhead

Discussion relating to version 1.2.x stable

Component cache overhead

Postby ventzy » Wed Sep 08, 2010 10:12 pm

I have strange (for me) situation.

My application is very modular and uses many components and partials. At one moment I decided to cache some of components to speed things up.

To test caching I duplicated prod env like cache_prod and enabled cache. Settings.yml looks like this:
Code: Select all
prod:
  .settings:
    logging_enabled:        on
    cache:                  off

cache_prod:
  .settings:
    logging_enabled:        on
    cache:                  on


cache.yml
Code: Select all
default:
  enabled:     off
  with_layout: false
  lifetime:    86400


I have no other cache.yml files in modules that turns cache on, and I thought that prod and cache_prod performance must be the same at this stage, but its not. cache_prod is actually almost twice slower than prod. cache_prod does not write any cache files.

When I setup cache_prod with Web Debug Bar, I can see in the log records like this:
Code: Select all
28   Info main   Call "modMenu->executeMenu()"
29   Info PartialView   Render "/modules/modMenu/templates/_menu.php"
30   Info ViewCacheManager   Generate cache key


So maybe the difference comes from "ViewCacheManager Generate cache key", but why it generates cache key, as this key does not seems to be used - it does not generate cache files and cache for the menu component is not enabled at all?

When I compare time needed for same partial (for which cache is not enabled) to render in cache enabled env and env with disabled cache, I see that first case is about 10 times slower. I am passing some model objects to the partials and if they are serialized for key generation, as far as I know this can be slow. If this is the case, I come again to the above question - why cache key is generated for module with disabled cache?
ventzy
Member
 
Posts: 30
Joined: Fri Jun 27, 2008 2:23 pm

Re: Component cache overhead

Postby ventzy » Thu Sep 09, 2010 5:04 pm

It seems that I found harder way "lazy_cache_key".

As documentations says:
lazy_cache_key
Default: true for new projects, false for upgraded projects
When enabled, the lazy_cache_key setting delays the creation of a cache key until after checking whether an action or partial is cacheable. This can result in a big performance improvement, depending on your usage of template partials.
ventzy
Member
 
Posts: 30
Joined: Fri Jun 27, 2008 2:23 pm


Return to symfony 1.2

Who is online

Users browsing this forum: No registered users and 0 guests