gdbm: reduce cache size to 10 57/76857/1 submit/tizen/20160628.013526
authortaeyoung <ty317.kim@samsung.com>
Mon, 27 Jun 2016 12:21:52 +0000 (21:21 +0900)
committertaeyoung <ty317.kim@samsung.com>
Mon, 27 Jun 2016 12:25:24 +0000 (21:25 +0900)
- Before reducing cache size, HEAP size allocated
  was 428kB with test app.
- After reducing cache size, HEAP size allocated
  is decreased to 64kB.
- The performance to read data is not decreased.

Change-Id: I68809bbbe3e1345b726bfdba3d8bd39e807f9381
Signed-off-by: taeyoung <ty317.kim@samsung.com>
src/system_info.c

index d61262e..ff4d7cf 100644 (file)
@@ -35,6 +35,8 @@
 #define KEY_MAX 256
 #define STR_MAX 256
 
+#define GDBM_CACHE_SIZE 10 /* GDBM default == 100 */
+
 enum tag_type {
        TAG_TYPE_PLATFORM,
        TAG_TYPE_CUSTOM,
@@ -69,6 +71,7 @@ static int db_get_value(enum tag_type tag, const char *key,
        datum d_data;
        int ret;
        char *tag_s;
+       int cache_size = GDBM_CACHE_SIZE;
 
        if (!key || !type || !value)
                return SYSTEM_INFO_ERROR_INVALID_PARAMETER;
@@ -90,6 +93,10 @@ static int db_get_value(enum tag_type tag, const char *key,
                return SYSTEM_INFO_ERROR_IO_ERROR;
        }
 
+       ret = gdbm_setopt(db, GDBM_CACHESIZE, &cache_size, sizeof(cache_size));
+       if (ret < 0)
+               _E("Failed to set cache size to (%d) (ret:%d)", cache_size, gdbm_errno);
+
        if (strstr(key, KEY_PREFIX) == key)
                snprintf(key_internal, sizeof(key_internal),
                                "%s:%s:%s", key, type, tag_s);
@@ -135,6 +142,7 @@ static int system_info_get_type(enum tag_type tag, const char *key,
        datum d_data;
        int ret, i;
        char *tag_s;
+       int cache_size = GDBM_CACHE_SIZE;
 
        if (!key || !type)
                return SYSTEM_INFO_ERROR_INVALID_PARAMETER;
@@ -156,6 +164,10 @@ static int system_info_get_type(enum tag_type tag, const char *key,
                return SYSTEM_INFO_ERROR_IO_ERROR;
        }
 
+       ret = gdbm_setopt(db, GDBM_CACHESIZE, &cache_size, sizeof(cache_size));
+       if (ret < 0)
+               _E("Failed to set cache size to (%d) (ret:%d)", cache_size, gdbm_errno);
+
        for (i = 0 ; i < ARRAY_SIZE(info_type); i++) {
                if (strstr(key, KEY_PREFIX) == key)
                        snprintf(key_internal, sizeof(key_internal),