diff options
-rw-r--r-- | src/bin/evas/evas_cserve2.h | 1 | ||||
-rw-r--r-- | src/bin/evas/evas_cserve2_cache.c | 7 | ||||
-rw-r--r-- | src/bin/evas/evas_cserve2_index.c | 38 |
3 files changed, 44 insertions, 2 deletions
diff --git a/src/bin/evas/evas_cserve2.h b/src/bin/evas/evas_cserve2.h index c0a703ab51..fda088fbce 100644 --- a/src/bin/evas/evas_cserve2.h +++ b/src/bin/evas/evas_cserve2.h | |||
@@ -388,5 +388,6 @@ int cserve2_shared_string_add(const char *str); | |||
388 | int cserve2_shared_string_ref(int id); | 388 | int cserve2_shared_string_ref(int id); |
389 | void cserve2_shared_string_del(int id); | 389 | void cserve2_shared_string_del(int id); |
390 | const char *cserve2_shared_string_get(int id); | 390 | const char *cserve2_shared_string_get(int id); |
391 | int cserve2_shared_strings_repack(Shared_Array_Repack_Skip_Cb skip, Eina_Compare_Cb cmp); | ||
391 | 392 | ||
392 | #endif /* _EVAS_CSERVE2_H */ | 393 | #endif /* _EVAS_CSERVE2_H */ |
diff --git a/src/bin/evas/evas_cserve2_cache.c b/src/bin/evas/evas_cserve2_cache.c index f351dd718d..b71ce019b8 100644 --- a/src/bin/evas/evas_cserve2_cache.c +++ b/src/bin/evas/evas_cserve2_cache.c | |||
@@ -318,8 +318,8 @@ static Eina_Bool | |||
318 | _repack_skip_cb(Shared_Array *sa EINA_UNUSED, const void *elem, | 318 | _repack_skip_cb(Shared_Array *sa EINA_UNUSED, const void *elem, |
319 | void *user_data EINA_UNUSED) | 319 | void *user_data EINA_UNUSED) |
320 | { | 320 | { |
321 | const File_Data *fd = elem; | 321 | const Shm_Object *obj = elem; |
322 | return (!fd->refcount); | 322 | return (!obj->refcount); |
323 | } | 323 | } |
324 | 324 | ||
325 | static void | 325 | static void |
@@ -411,6 +411,9 @@ skip_images: | |||
411 | } | 411 | } |
412 | skip_fonts: | 412 | skip_fonts: |
413 | 413 | ||
414 | if (cserve2_shared_strings_repack(_repack_skip_cb, _shm_object_id_cmp_cb) == 1) | ||
415 | updated = EINA_TRUE; | ||
416 | |||
414 | if (updated) | 417 | if (updated) |
415 | { | 418 | { |
416 | // TODO: Update strings table generation_id? | 419 | // TODO: Update strings table generation_id? |
diff --git a/src/bin/evas/evas_cserve2_index.c b/src/bin/evas/evas_cserve2_index.c index fdff6b5177..2c4d9dc15b 100644 --- a/src/bin/evas/evas_cserve2_index.c +++ b/src/bin/evas/evas_cserve2_index.c | |||
@@ -896,6 +896,8 @@ cserve2_shared_mempool_generation_id_set(Shared_Mempool *sm, int generation_id) | |||
896 | 896 | ||
897 | // Shared strings | 897 | // Shared strings |
898 | 898 | ||
899 | static int _shared_strings_unref_items = 0; | ||
900 | |||
899 | const char * | 901 | const char * |
900 | cserve2_shared_strings_table_name_get() | 902 | cserve2_shared_strings_table_name_get() |
901 | { | 903 | { |
@@ -957,7 +959,12 @@ new_entry: | |||
957 | int | 959 | int |
958 | cserve2_shared_string_ref(int id) | 960 | cserve2_shared_string_ref(int id) |
959 | { | 961 | { |
962 | Index_Entry *ie; | ||
960 | if (id <= 0) return 0; | 963 | if (id <= 0) return 0; |
964 | ie = _shared_index_entry_get_by_id(_string_mempool->index, id); | ||
965 | if (!ie) return 0; | ||
966 | if (!ie->refcount) | ||
967 | _string_mempool--; | ||
961 | return cserve2_shared_mempool_buffer_ref(_string_mempool, id); | 968 | return cserve2_shared_mempool_buffer_ref(_string_mempool, id); |
962 | } | 969 | } |
963 | 970 | ||
@@ -975,6 +982,7 @@ cserve2_shared_string_del(int id) | |||
975 | CRIT("Invalid free"); | 982 | CRIT("Invalid free"); |
976 | } | 983 | } |
977 | } | 984 | } |
985 | _shared_strings_unref_items++; | ||
978 | } | 986 | } |
979 | 987 | ||
980 | const char * | 988 | const char * |
@@ -984,6 +992,35 @@ cserve2_shared_string_get(int id) | |||
984 | return cserve2_shared_mempool_buffer_get(_string_mempool, id); | 992 | return cserve2_shared_mempool_buffer_get(_string_mempool, id); |
985 | } | 993 | } |
986 | 994 | ||
995 | int | ||
996 | cserve2_shared_strings_repack(Shared_Array_Repack_Skip_Cb skip, | ||
997 | Eina_Compare_Cb cmp) | ||
998 | { | ||
999 | int count; | ||
1000 | |||
1001 | if (!_string_mempool->index) return -1; | ||
1002 | count = _string_mempool->index->lastid; | ||
1003 | if (!count) return -1; | ||
1004 | if (_shared_strings_unref_items * 100 / count >= 25 | ||
1005 | && _shared_strings_unref_items > 100) | ||
1006 | { | ||
1007 | Shared_Array *sa; | ||
1008 | int genid; | ||
1009 | |||
1010 | genid = _string_mempool->index->sa->header->generation_id + 1; | ||
1011 | sa = cserve2_shared_array_repack(_string_mempool->index->sa, genid, | ||
1012 | skip, cmp, NULL); | ||
1013 | if (!sa) return -1; | ||
1014 | |||
1015 | cserve2_shared_array_del(_string_mempool->index->sa); | ||
1016 | _string_mempool->index->sa = sa; | ||
1017 | _shared_strings_unref_items = 0; | ||
1018 | return 1; | ||
1019 | } | ||
1020 | |||
1021 | return 0; | ||
1022 | } | ||
1023 | |||
987 | 1024 | ||
988 | 1025 | ||
989 | // Init/destroy | 1026 | // Init/destroy |
@@ -1002,6 +1039,7 @@ cserve2_shared_index_init(void) | |||
1002 | 1039 | ||
1003 | memcpy(faketag, &ifaketag, sizeof(int)); | 1040 | memcpy(faketag, &ifaketag, sizeof(int)); |
1004 | cserve2_shared_string_add(faketag); | 1041 | cserve2_shared_string_add(faketag); |
1042 | _shared_strings_unref_items = 0; | ||
1005 | } | 1043 | } |
1006 | _instances++; | 1044 | _instances++; |
1007 | } | 1045 | } |