evas/cserve2: Set default LRU size to 4Mb or env-based
authorJean-Philippe Andre <jp.andre@samsung.com>
Wed, 26 Jun 2013 07:31:38 +0000 (16:31 +0900)
committerCedric Bail <cedric.bail@samsung.com>
Tue, 2 Jul 2013 07:58:10 +0000 (16:58 +0900)
The LRU should not be limited to 0 byte otherwise all scaled
images will be dropped and reloaded constantly, killing the
performance.
The size is inspired from the scalecache's size of 4Mb.

Variable: EVAS_CSERVE2_SIZE (number in Mb)
Signed-off-by: Cedric Bail <cedric.bail@samsung.com>
src/lib/evas/cache2/evas_cache2.c

index 1e9b24f..f753233 100644 (file)
@@ -30,6 +30,9 @@
  */
 #define HKEY_LOAD_OPTS_STR_LEN 215
 
+// Default LRU size. If 0, all scaled images will be dropped instantly.
+#define DEFAULT_CACHE_LRU_SIZE (4*1024*1024)
+
 static void _evas_cache_image_dirty_add(Image_Entry *im);
 static void _evas_cache_image_dirty_del(Image_Entry *im);
 static void _evas_cache_image_activ_add(Image_Entry *im);
@@ -484,12 +487,19 @@ on_error:
 EAPI Evas_Cache2 *
 evas_cache2_init(const Evas_Cache2_Image_Func *cb)
 {
+   char *env;
    Evas_Cache2 *cache = calloc(1, sizeof(Evas_Cache2));
 
    cache->func = *cb;
    cache->activ = eina_hash_string_superfast_new(NULL);
    cache->inactiv = eina_hash_string_superfast_new(NULL);
 
+   env = getenv("EVAS_CSERVE2_SIZE");
+   if (env)
+     cache->limit = atoi(env) * 1024 * 1024;
+   if (!env || (cache->limit < 0))
+     cache->limit = DEFAULT_CACHE_LRU_SIZE;
+
    return cache;
 }