summaryrefslogtreecommitdiff
path: root/src/lib/eet
diff options
context:
space:
mode:
authorDerek Foreman <derek.foreman.samsung@gmail.com>2018-11-15 15:26:36 -0600
committerDerek Foreman <derek.foreman.samsung@gmail.com>2018-11-16 12:16:07 -0600
commit2464cf6648811beff343c5c24e269f163c2728d7 (patch)
tree25672485a54e29c9ff3386c5b3a0fb4d934998c2 /src/lib/eet
parenta9f1b588b1a5019d5ac310ac51b1d8a7cfeb861f (diff)
eet: Remove pointer deduplication
After my previous changes, the only thing left that's adding duplicate pointers should be string allocations, either direct (which have no free) or stringshare which need to be "freed" for each duplicate as it's a refcounting mechanism. This speeds up parsing the theme file modestly (10ms faster launching elementary_test for me), and should also prevent leaking every stringshare that's on the freelist if an eet load fails. I would not be at all surprised if there are still bugs in the fail path, but I hope this at least mitigates failure tracking's impact on successful parse times. Differential Revision: https://phab.enlightenment.org/D7282 Signed-off-by: Derek Foreman <derek.foreman.samsung@gmail.com>
Diffstat (limited to 'src/lib/eet')
-rw-r--r--src/lib/eet/eet_data.c129
1 files changed, 34 insertions, 95 deletions
diff --git a/src/lib/eet/eet_data.c b/src/lib/eet/eet_data.c
index 2fe8e0343a..5a5250b174 100644
--- a/src/lib/eet/eet_data.c
+++ b/src/lib/eet/eet_data.c
@@ -201,11 +201,10 @@ struct _Eet_Data_Encode_Hash_Info
201 Eet_Dictionary *ed; 201 Eet_Dictionary *ed;
202}; 202};
203 203
204#define EET_FREE_COUNT 256
205struct _Eet_Free 204struct _Eet_Free
206{ 205{
207 int ref; 206 int ref;
208 Eina_Array list[EET_FREE_COUNT]; 207 Eina_Array list;
209}; 208};
210 209
211struct _Eet_Free_Context 210struct _Eet_Free_Context
@@ -2424,89 +2423,44 @@ eet_data_write(Eet_File *ef,
2424static void 2423static void
2425eet_free_context_init(Eet_Free_Context *context) 2424eet_free_context_init(Eet_Free_Context *context)
2426{ 2425{
2427 unsigned int i = 0;
2428
2429 memset(context, 0, sizeof (Eet_Free_Context)); 2426 memset(context, 0, sizeof (Eet_Free_Context));
2430 for (i = 0; i < EET_FREE_COUNT; ++i) 2427
2431 { 2428 eina_array_step_set(&context->freelist.list,
2432 eina_array_step_set(&context->freelist.list[i], 2429 sizeof (context->freelist.list),
2433 sizeof (context->freelist.list[i]), 2430 32);
2434 32); 2431 eina_array_step_set(&context->freelist_array.list,
2435 eina_array_step_set(&context->freelist_array.list[i], 2432 sizeof (context->freelist.list),
2436 sizeof (context->freelist.list[i]), 2433 32);
2437 32); 2434 eina_array_step_set(&context->freelist_list.list,
2438 eina_array_step_set(&context->freelist_list.list[i], 2435 sizeof (context->freelist.list),
2439 sizeof (context->freelist.list[i]), 2436 32);
2440 32); 2437 eina_array_step_set(&context->freelist_hash.list,
2441 eina_array_step_set(&context->freelist_hash.list[i], 2438 sizeof (context->freelist.list),
2442 sizeof (context->freelist.list[i]), 2439 32);
2443 32); 2440 eina_array_step_set(&context->freelist_str.list,
2444 eina_array_step_set(&context->freelist_str.list[i], 2441 sizeof (context->freelist.list),
2445 sizeof (context->freelist.list[i]), 2442 32);
2446 32); 2443 eina_array_step_set(&context->freelist_direct_str.list,
2447 eina_array_step_set(&context->freelist_direct_str.list[i], 2444 sizeof (context->freelist.list),
2448 sizeof (context->freelist.list[i]), 2445 32);
2449 32);
2450 }
2451} 2446}
2452 2447
2453static void 2448static void
2454eet_free_context_shutdown(Eet_Free_Context *context) 2449eet_free_context_shutdown(Eet_Free_Context *context)
2455{ 2450{
2456 unsigned int i = 0; 2451 eina_array_flush(&context->freelist.list);
2457 2452 eina_array_flush(&context->freelist_array.list);
2458 for (i = 0; i < EET_FREE_COUNT; ++i) 2453 eina_array_flush(&context->freelist_list.list);
2459 { 2454 eina_array_flush(&context->freelist_hash.list);
2460 eina_array_flush(&context->freelist.list[i]); 2455 eina_array_flush(&context->freelist_str.list);
2461 eina_array_flush(&context->freelist_array.list[i]); 2456 eina_array_flush(&context->freelist_direct_str.list);
2462 eina_array_flush(&context->freelist_list.list[i]);
2463 eina_array_flush(&context->freelist_hash.list[i]);
2464 eina_array_flush(&context->freelist_str.list[i]);
2465 eina_array_flush(&context->freelist_direct_str.list[i]);
2466 }
2467}
2468
2469static int
2470_eet_free_hash(void *data)
2471{
2472#ifdef _WIN64
2473 __int64 ptr = (UINT_PTR)data;
2474#else /* ifdef _WIN64 */
2475 unsigned long ptr = (unsigned long)(data);
2476#endif /* ifdef _WIN64 */
2477 int hash;
2478
2479 hash = ptr;
2480 hash ^= ptr >> 8;
2481 hash ^= ptr >> 16;
2482 hash ^= ptr >> 24;
2483
2484#if defined (_WIN64) || ((!defined (_WIN32)) && (LONG_BIT != 32))
2485 hash ^= ptr >> 32;
2486 hash ^= ptr >> 40;
2487 hash ^= ptr >> 48;
2488 hash ^= ptr >> 56;
2489#endif /* if defined (_WIN64) || ((!defined (_WIN32)) && (LONG_BIT != 32)) */
2490
2491 return hash & 0xFF;
2492} 2457}
2493 2458
2494static void 2459static void
2495_eet_free_add(Eet_Free *ef, 2460_eet_free_add(Eet_Free *ef,
2496 void *data) 2461 void *data)
2497{ 2462{
2498 void *track; 2463 eina_array_push(&ef->list, data);
2499 Eina_Array_Iterator it;
2500 unsigned int i;
2501 int hash;
2502
2503 hash = _eet_free_hash(data);
2504
2505 EINA_ARRAY_ITER_NEXT(&ef->list[hash], i, track, it)
2506 if (track == data)
2507 return;
2508
2509 eina_array_push(&ef->list[hash], data);
2510} 2464}
2511 2465
2512#if 0 2466#if 0
@@ -2534,13 +2488,10 @@ _eet_free_del(Eet_Free *ef,
2534static void 2488static void
2535_eet_free_reset(Eet_Free *ef) 2489_eet_free_reset(Eet_Free *ef)
2536{ 2490{
2537 unsigned int i;
2538
2539 if (ef->ref > 0) 2491 if (ef->ref > 0)
2540 return; 2492 return;
2541 2493
2542 for (i = 0; i < EET_FREE_COUNT; ++i) 2494 eina_array_clean(&ef->list);
2543 eina_array_clean(&ef->list[i]);
2544} 2495}
2545 2496
2546static void 2497static void
@@ -2569,14 +2520,12 @@ _eet_freelist_free(Eet_Free_Context *context,
2569{ 2520{
2570 void *track; 2521 void *track;
2571 Eina_Array_Iterator it; 2522 Eina_Array_Iterator it;
2572 unsigned int j;
2573 unsigned int i; 2523 unsigned int i;
2574 2524
2575 if (context->freelist.ref > 0) 2525 if (context->freelist.ref > 0)
2576 return; 2526 return;
2577 2527
2578 for (j = 0; j < EET_FREE_COUNT; ++j) 2528 EINA_ARRAY_ITER_NEXT(&context->freelist.list, i, track, it)
2579 EINA_ARRAY_ITER_NEXT(&context->freelist.list[j], i, track, it)
2580 if (track) 2529 if (track)
2581 { 2530 {
2582 if (edd) 2531 if (edd)
@@ -2599,14 +2548,12 @@ _eet_freelist_array_free(Eet_Free_Context *context,
2599{ 2548{
2600 void *track; 2549 void *track;
2601 Eina_Array_Iterator it; 2550 Eina_Array_Iterator it;
2602 unsigned int j;
2603 unsigned int i; 2551 unsigned int i;
2604 2552
2605 if (context->freelist_array.ref > 0) 2553 if (context->freelist_array.ref > 0)
2606 return; 2554 return;
2607 2555
2608 for (j = 0; j < EET_FREE_COUNT; ++j) 2556 EINA_ARRAY_ITER_NEXT(&context->freelist_array.list, i, track, it)
2609 EINA_ARRAY_ITER_NEXT(&context->freelist_array.list[j], i, track, it)
2610 if (track) 2557 if (track)
2611 { 2558 {
2612 if (edd) 2559 if (edd)
@@ -2634,14 +2581,12 @@ _eet_freelist_list_free(Eet_Free_Context *context,
2634{ 2581{
2635 void *track; 2582 void *track;
2636 Eina_Array_Iterator it; 2583 Eina_Array_Iterator it;
2637 unsigned int j;
2638 unsigned int i; 2584 unsigned int i;
2639 2585
2640 if (context->freelist_list.ref > 0) 2586 if (context->freelist_list.ref > 0)
2641 return; 2587 return;
2642 2588
2643 for (j = 0; j < EET_FREE_COUNT; ++j) 2589 EINA_ARRAY_ITER_NEXT(&context->freelist_list.list, i, track, it)
2644 EINA_ARRAY_ITER_NEXT(&context->freelist_list.list[j], i, track, it)
2645 if (track) 2590 if (track)
2646 { 2591 {
2647 if (edd) 2592 if (edd)
@@ -2662,14 +2607,12 @@ _eet_freelist_str_free(Eet_Free_Context *context,
2662{ 2607{
2663 void *track; 2608 void *track;
2664 Eina_Array_Iterator it; 2609 Eina_Array_Iterator it;
2665 unsigned int j;
2666 unsigned int i; 2610 unsigned int i;
2667 2611
2668 if (context->freelist_str.ref > 0) 2612 if (context->freelist_str.ref > 0)
2669 return; 2613 return;
2670 2614
2671 for (j = 0; j < EET_FREE_COUNT; ++j) 2615 EINA_ARRAY_ITER_NEXT(&context->freelist_str.list, i, track, it)
2672 EINA_ARRAY_ITER_NEXT(&context->freelist_str.list[j], i, track, it)
2673 if (track) 2616 if (track)
2674 { 2617 {
2675 if (edd) 2618 if (edd)
@@ -2692,14 +2635,12 @@ _eet_freelist_direct_str_free(Eet_Free_Context *context,
2692{ 2635{
2693 void *track; 2636 void *track;
2694 Eina_Array_Iterator it; 2637 Eina_Array_Iterator it;
2695 unsigned int j;
2696 unsigned int i; 2638 unsigned int i;
2697 2639
2698 if (context->freelist_direct_str.ref > 0) 2640 if (context->freelist_direct_str.ref > 0)
2699 return; 2641 return;
2700 2642
2701 for (j = 0; j < EET_FREE_COUNT; ++j) 2643 EINA_ARRAY_ITER_NEXT(&context->freelist_str.list, i, track, it)
2702 EINA_ARRAY_ITER_NEXT(&context->freelist_str.list[j], i, track, it)
2703 if (track) 2644 if (track)
2704 { 2645 {
2705 if (edd) 2646 if (edd)
@@ -2722,14 +2663,12 @@ _eet_freelist_hash_free(Eet_Free_Context *context,
2722{ 2663{
2723 void *track; 2664 void *track;
2724 Eina_Array_Iterator it; 2665 Eina_Array_Iterator it;
2725 unsigned int j;
2726 unsigned int i; 2666 unsigned int i;
2727 2667
2728 if (context->freelist_hash.ref > 0) 2668 if (context->freelist_hash.ref > 0)
2729 return; 2669 return;
2730 2670
2731 for (j = 0; j < EET_FREE_COUNT; ++j) 2671 EINA_ARRAY_ITER_NEXT(&context->freelist_hash.list, i, track, it)
2732 EINA_ARRAY_ITER_NEXT(&context->freelist_hash.list[j], i, track, it)
2733 if (track) 2672 if (track)
2734 { 2673 {
2735 if (edd) 2674 if (edd)