summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bin/evas/evas_cserve2.h2
-rw-r--r--src/bin/evas/evas_cserve2_cache.c8
-rw-r--r--src/bin/evas/evas_cserve2_fonts.c22
-rw-r--r--src/bin/evas/evas_cserve2_index.c15
-rw-r--r--src/bin/evas/evas_cserve2_shm.c14
5 files changed, 26 insertions, 35 deletions
diff --git a/src/bin/evas/evas_cserve2.h b/src/bin/evas/evas_cserve2.h
index a90dc079c7..219bb0d7f7 100644
--- a/src/bin/evas/evas_cserve2.h
+++ b/src/bin/evas/evas_cserve2.h
@@ -307,7 +307,7 @@ size_t cserve2_shm_map_size_get(const Shm_Handle *shm);
307size_t cserve2_shm_size_get(const Shm_Handle *shm); 307size_t cserve2_shm_size_get(const Shm_Handle *shm);
308void *cserve2_shm_map(Shm_Handle *shm); 308void *cserve2_shm_map(Shm_Handle *shm);
309void cserve2_shm_unmap(Shm_Handle *shm); 309void cserve2_shm_unmap(Shm_Handle *shm);
310size_t cserve2_shm_size_normalize(size_t size); 310size_t cserve2_shm_size_normalize(size_t size, size_t align);
311 311
312void cserve2_command_run(Client *client, Message_Type type); 312void cserve2_command_run(Client *client, Message_Type type);
313 313
diff --git a/src/bin/evas/evas_cserve2_cache.c b/src/bin/evas/evas_cserve2_cache.c
index dc2939b5bf..15ce2c36f4 100644
--- a/src/bin/evas/evas_cserve2_cache.c
+++ b/src/bin/evas/evas_cserve2_cache.c
@@ -171,6 +171,7 @@ static int max_font_usage = 10 * 4 * 1024; /* in kbytes */
171static int font_mem_usage = 0; 171static int font_mem_usage = 0;
172 172
173#define MAX_PREEMPTIVE_LOAD_SIZE (320*320*4) 173#define MAX_PREEMPTIVE_LOAD_SIZE (320*320*4)
174#define ARRAY_REPACK_TRIGGER_PERCENT 25 // repack when array conains 25% holes
174 175
175#ifdef DEBUG_LOAD_TIME 176#ifdef DEBUG_LOAD_TIME
176static int 177static int
@@ -354,7 +355,7 @@ _repack()
354 355
355 count = cserve2_shared_array_size_get(_file_data_array); 356 count = cserve2_shared_array_size_get(_file_data_array);
356 if ((count > 0) && (_freed_file_entry_count > 100 || 357 if ((count > 0) && (_freed_file_entry_count > 100 ||
357 ((_freed_file_entry_count * 100) / count >= 10))) 358 ((_freed_file_entry_count * 100) / count >= ARRAY_REPACK_TRIGGER_PERCENT)))
358 { 359 {
359 DBG("Repacking file data array: %s", 360 DBG("Repacking file data array: %s",
360 cserve2_shared_array_name_get(_file_data_array)); 361 cserve2_shared_array_name_get(_file_data_array));
@@ -379,7 +380,7 @@ skip_files:
379 380
380 count = cserve2_shared_array_size_get(_image_data_array); 381 count = cserve2_shared_array_size_get(_image_data_array);
381 if ((count > 0) && (_freed_image_entry_count > 100 || 382 if ((count > 0) && (_freed_image_entry_count > 100 ||
382 ((_freed_image_entry_count * 100) / count >= 10))) 383 ((_freed_image_entry_count * 100) / count >= ARRAY_REPACK_TRIGGER_PERCENT)))
383 { 384 {
384 DBG("Repacking image data array: %s", 385 DBG("Repacking image data array: %s",
385 cserve2_shared_array_name_get(_image_data_array)); 386 cserve2_shared_array_name_get(_image_data_array));
@@ -405,7 +406,7 @@ skip_images:
405 406
406 count = cserve2_shared_array_size_get(_font_data_array); 407 count = cserve2_shared_array_size_get(_font_data_array);
407 if ((count > 0) && (_freed_font_entry_count > 100 || 408 if ((count > 0) && (_freed_font_entry_count > 100 ||
408 ((_freed_font_entry_count * 100) / count >= 10))) 409 ((_freed_font_entry_count * 100) / count >= ARRAY_REPACK_TRIGGER_PERCENT)))
409 { 410 {
410 DBG("Repacking font data array: %s", 411 DBG("Repacking font data array: %s",
411 cserve2_shared_array_name_get(_font_data_array)); 412 cserve2_shared_array_name_get(_font_data_array));
@@ -1145,7 +1146,6 @@ _file_data_free(File_Data *fd)
1145 cserve2_shared_string_del(fd->key); 1146 cserve2_shared_string_del(fd->key);
1146 cserve2_shared_string_del(fd->path); 1147 cserve2_shared_string_del(fd->path);
1147 cserve2_shared_string_del(fd->loader_data); 1148 cserve2_shared_string_del(fd->loader_data);
1148 memset((char *) fd + sizeof(fd->id), 0, sizeof(*fd) - sizeof(fd->id));
1149 } 1149 }
1150} 1150}
1151 1151
diff --git a/src/bin/evas/evas_cserve2_fonts.c b/src/bin/evas/evas_cserve2_fonts.c
index b9da989d28..51b87fe319 100644
--- a/src/bin/evas/evas_cserve2_fonts.c
+++ b/src/bin/evas/evas_cserve2_fonts.c
@@ -26,7 +26,7 @@
26#define _EVAS_FONT_SLANT_TAN 0.221694663 26#define _EVAS_FONT_SLANT_TAN 0.221694663
27 27
28#define CHECK_CHARS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" 28#define CHECK_CHARS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
29#define MIN_GLYPHS 50 29#define MIN_GLYPHS 100 // 26*2 + a nice margin :)
30#define MAX_CACHE_SIZE 1 * 1024 * 1024 // 1MB 30#define MAX_CACHE_SIZE 1 * 1024 * 1024 // 1MB
31 31
32#define EVAS_FONT_ROUND_26_6_TO_INT(x) \ 32#define EVAS_FONT_ROUND_26_6_TO_INT(x) \
@@ -406,24 +406,6 @@ end:
406} 406}
407 407
408static unsigned int 408static unsigned int
409_font_slave_int_shm_prev_calculate(unsigned int size, unsigned int nglyphs)
410{
411 unsigned int average;
412 unsigned int newsize;
413
414 if (!nglyphs) return cserve2_shm_size_normalize(1);
415 average = size / nglyphs;
416
417 newsize = MIN_GLYPHS * average;
418 newsize = cserve2_shm_size_normalize(newsize);
419
420 if (newsize > MAX_CACHE_SIZE)
421 return MAX_CACHE_SIZE;
422
423 return newsize;
424}
425
426static unsigned int
427_font_slave_int_shm_calculate(Font_Info *fi, unsigned int hint) 409_font_slave_int_shm_calculate(Font_Info *fi, unsigned int hint)
428{ 410{
429 const char *c; 411 const char *c;
@@ -441,7 +423,7 @@ _font_slave_int_shm_calculate(Font_Info *fi, unsigned int hint)
441 average = size / i; // average glyph size 423 average = size / i; // average glyph size
442 size = MIN_GLYPHS * average; 424 size = MIN_GLYPHS * average;
443 425
444 size = cserve2_shm_size_normalize(size); 426 size = cserve2_shm_size_normalize(size, 0);
445 427
446 if (size > MAX_CACHE_SIZE) 428 if (size > MAX_CACHE_SIZE)
447 return MAX_CACHE_SIZE; // Assumes no glyph will be bigger than this 429 return MAX_CACHE_SIZE; // Assumes no glyph will be bigger than this
diff --git a/src/bin/evas/evas_cserve2_index.c b/src/bin/evas/evas_cserve2_index.c
index ce5b93a6fe..0a3a6299c6 100644
--- a/src/bin/evas/evas_cserve2_index.c
+++ b/src/bin/evas/evas_cserve2_index.c
@@ -64,6 +64,9 @@ struct _Block
64// fragmentation (after del). 16 is convenient for debugging with hd :) 64// fragmentation (after del). 16 is convenient for debugging with hd :)
65#define DATA_BLOCKSIZE 8 65#define DATA_BLOCKSIZE 8
66 66
67// Recommended minimum size for arrays and mempools
68#define ARRAY_MINSIZE (32 * 1024)
69
67static inline int 70static inline int
68_data_blocksize_roundup(int len) 71_data_blocksize_roundup(int len)
69{ 72{
@@ -160,7 +163,7 @@ _shared_data_shm_new(const char *infix, int size)
160 ds = calloc(1, sizeof(Data_Shm)); 163 ds = calloc(1, sizeof(Data_Shm));
161 if (!ds) return NULL; 164 if (!ds) return NULL;
162 165
163 mapping_size = cserve2_shm_size_normalize((size_t) size); 166 mapping_size = cserve2_shm_size_normalize((size_t) size, 0);
164 167
165 ds->shm = cserve2_shm_request(infix, mapping_size); 168 ds->shm = cserve2_shm_request(infix, mapping_size);
166 if (!ds->shm) 169 if (!ds->shm)
@@ -200,7 +203,7 @@ _shared_data_shm_resize(Data_Shm *ds, size_t newsize)
200 if (newsize <= 0) 203 if (newsize <= 0)
201 return -1; 204 return -1;
202 205
203 mapping_size = cserve2_shm_size_normalize(newsize); 206 mapping_size = cserve2_shm_size_normalize(newsize, ARRAY_MINSIZE);
204 cserve2_shm_unmap(ds->shm); 207 cserve2_shm_unmap(ds->shm);
205 ds->data = NULL; 208 ds->data = NULL;
206 209
@@ -242,7 +245,8 @@ cserve2_shared_array_new(int tag, int generation_id, int elemsize, int initcount
242 245
243 if (!initcount) initcount = 1; 246 if (!initcount) initcount = 1;
244 mapping_size = cserve2_shm_size_normalize(elemsize * initcount 247 mapping_size = cserve2_shm_size_normalize(elemsize * initcount
245 + sizeof(Shared_Array_Header)); 248 + sizeof(Shared_Array_Header),
249 ARRAY_MINSIZE);
246 ds = _shared_data_shm_new("array", mapping_size); 250 ds = _shared_data_shm_new("array", mapping_size);
247 if (!ds) 251 if (!ds)
248 { 252 {
@@ -330,7 +334,8 @@ cserve2_shared_array_size_set(Shared_Array *sa, int newcount)
330 334
331 if (!sa) return -1; 335 if (!sa) return -1;
332 mapping_size = cserve2_shm_size_normalize(sa->header->elemsize * newcount 336 mapping_size = cserve2_shm_size_normalize(sa->header->elemsize * newcount
333 + sizeof(Shared_Array_Header)); 337 + sizeof(Shared_Array_Header),
338 ARRAY_MINSIZE);
334 if (_shared_data_shm_resize(sa->ds, mapping_size) < 0) 339 if (_shared_data_shm_resize(sa->ds, mapping_size) < 0)
335 { 340 {
336 sa->header = NULL; 341 sa->header = NULL;
@@ -638,7 +643,7 @@ cserve2_shared_mempool_new(int indextag, int generation_id, int initsize)
638 if (!sm) return NULL; 643 if (!sm) return NULL;
639 644
640 if (!initsize) initsize = 1; 645 if (!initsize) initsize = 1;
641 mapping_size = cserve2_shm_size_normalize((size_t) initsize); 646 mapping_size = cserve2_shm_size_normalize((size_t) initsize, ARRAY_MINSIZE);
642 647
643 sm->ds = _shared_data_shm_new("mempool", mapping_size); 648 sm->ds = _shared_data_shm_new("mempool", mapping_size);
644 if (!sm->ds) 649 if (!sm->ds)
diff --git a/src/bin/evas/evas_cserve2_shm.c b/src/bin/evas/evas_cserve2_shm.c
index 2045cdd8ca..d95afc7782 100644
--- a/src/bin/evas/evas_cserve2_shm.c
+++ b/src/bin/evas/evas_cserve2_shm.c
@@ -35,7 +35,7 @@ struct _Shm_Handle
35static int id = 0; 35static int id = 0;
36 36
37size_t 37size_t
38cserve2_shm_size_normalize(size_t size) 38cserve2_shm_size_normalize(size_t size, size_t align)
39{ 39{
40 long pagesize; 40 long pagesize;
41 size_t normalized; 41 size_t normalized;
@@ -47,7 +47,11 @@ cserve2_shm_size_normalize(size_t size)
47 pagesize = 4096; 47 pagesize = 4096;
48 } 48 }
49 49
50 normalized = ((size + pagesize - 1) / pagesize) * pagesize; 50 if (align)
51 align = ((align + pagesize - 1) / pagesize) * pagesize;
52 else
53 align = pagesize;
54 normalized = ((size + align - 1) / align) * align;
51 55
52 return normalized; 56 return normalized;
53} 57}
@@ -89,7 +93,7 @@ cserve2_shm_request(const char *infix, size_t size)
89 } 93 }
90 } while (fd == -1); 94 } while (fd == -1);
91 95
92 map_size = cserve2_shm_size_normalize(size); 96 map_size = cserve2_shm_size_normalize(size, 0);
93 97
94 if (ftruncate(fd, map_size) == -1) 98 if (ftruncate(fd, map_size) == -1)
95 { 99 {
@@ -135,7 +139,7 @@ cserve2_shm_segment_request(Shm_Handle *shm, size_t size)
135 return NULL; 139 return NULL;
136 } 140 }
137 141
138 map_size = cserve2_shm_size_normalize(size); 142 map_size = cserve2_shm_size_normalize(size, 0);
139 map_size += map->length; 143 map_size += map->length;
140 144
141 if (ftruncate(fd, map_size) == -1) 145 if (ftruncate(fd, map_size) == -1)
@@ -186,7 +190,7 @@ cserve2_shm_resize(Shm_Handle *shm, size_t newsize)
186 return NULL; 190 return NULL;
187 } 191 }
188 192
189 map_size = cserve2_shm_size_normalize(newsize); 193 map_size = cserve2_shm_size_normalize(newsize, 0);
190 if (ftruncate(fd, map_size)) 194 if (ftruncate(fd, map_size))
191 { 195 {
192 ERR("Could not set the size of the shm: %m"); 196 ERR("Could not set the size of the shm: %m");