From: taeyoung Date: Mon, 27 Jun 2016 12:21:52 +0000 (+0900) Subject: gdbm: reduce cache size to 10 X-Git-Tag: submit/tizen/20160628.013526^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7e73c33ecbe3c8187cba3eab433c6ce6661c99ae;p=platform%2Fcore%2Fapi%2Fsystem-info.git gdbm: reduce cache size to 10 - 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 --- diff --git a/src/system_info.c b/src/system_info.c index d61262e..ff4d7cf 100644 --- a/src/system_info.c +++ b/src/system_info.c @@ -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),