forked from enlightenment/efl
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>
This commit is contained in:
parent
a9f1b588b1
commit
2464cf6648
|
@ -201,11 +201,10 @@ struct _Eet_Data_Encode_Hash_Info
|
||||||
Eet_Dictionary *ed;
|
Eet_Dictionary *ed;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define EET_FREE_COUNT 256
|
|
||||||
struct _Eet_Free
|
struct _Eet_Free
|
||||||
{
|
{
|
||||||
int ref;
|
int ref;
|
||||||
Eina_Array list[EET_FREE_COUNT];
|
Eina_Array list;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _Eet_Free_Context
|
struct _Eet_Free_Context
|
||||||
|
@ -2424,89 +2423,44 @@ eet_data_write(Eet_File *ef,
|
||||||
static void
|
static void
|
||||||
eet_free_context_init(Eet_Free_Context *context)
|
eet_free_context_init(Eet_Free_Context *context)
|
||||||
{
|
{
|
||||||
unsigned int i = 0;
|
|
||||||
|
|
||||||
memset(context, 0, sizeof (Eet_Free_Context));
|
memset(context, 0, sizeof (Eet_Free_Context));
|
||||||
for (i = 0; i < EET_FREE_COUNT; ++i)
|
|
||||||
{
|
eina_array_step_set(&context->freelist.list,
|
||||||
eina_array_step_set(&context->freelist.list[i],
|
sizeof (context->freelist.list),
|
||||||
sizeof (context->freelist.list[i]),
|
32);
|
||||||
32);
|
eina_array_step_set(&context->freelist_array.list,
|
||||||
eina_array_step_set(&context->freelist_array.list[i],
|
sizeof (context->freelist.list),
|
||||||
sizeof (context->freelist.list[i]),
|
32);
|
||||||
32);
|
eina_array_step_set(&context->freelist_list.list,
|
||||||
eina_array_step_set(&context->freelist_list.list[i],
|
sizeof (context->freelist.list),
|
||||||
sizeof (context->freelist.list[i]),
|
32);
|
||||||
32);
|
eina_array_step_set(&context->freelist_hash.list,
|
||||||
eina_array_step_set(&context->freelist_hash.list[i],
|
sizeof (context->freelist.list),
|
||||||
sizeof (context->freelist.list[i]),
|
32);
|
||||||
32);
|
eina_array_step_set(&context->freelist_str.list,
|
||||||
eina_array_step_set(&context->freelist_str.list[i],
|
sizeof (context->freelist.list),
|
||||||
sizeof (context->freelist.list[i]),
|
32);
|
||||||
32);
|
eina_array_step_set(&context->freelist_direct_str.list,
|
||||||
eina_array_step_set(&context->freelist_direct_str.list[i],
|
sizeof (context->freelist.list),
|
||||||
sizeof (context->freelist.list[i]),
|
32);
|
||||||
32);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
eet_free_context_shutdown(Eet_Free_Context *context)
|
eet_free_context_shutdown(Eet_Free_Context *context)
|
||||||
{
|
{
|
||||||
unsigned int i = 0;
|
eina_array_flush(&context->freelist.list);
|
||||||
|
eina_array_flush(&context->freelist_array.list);
|
||||||
for (i = 0; i < EET_FREE_COUNT; ++i)
|
eina_array_flush(&context->freelist_list.list);
|
||||||
{
|
eina_array_flush(&context->freelist_hash.list);
|
||||||
eina_array_flush(&context->freelist.list[i]);
|
eina_array_flush(&context->freelist_str.list);
|
||||||
eina_array_flush(&context->freelist_array.list[i]);
|
eina_array_flush(&context->freelist_direct_str.list);
|
||||||
eina_array_flush(&context->freelist_list.list[i]);
|
|
||||||
eina_array_flush(&context->freelist_hash.list[i]);
|
|
||||||
eina_array_flush(&context->freelist_str.list[i]);
|
|
||||||
eina_array_flush(&context->freelist_direct_str.list[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
_eet_free_hash(void *data)
|
|
||||||
{
|
|
||||||
#ifdef _WIN64
|
|
||||||
__int64 ptr = (UINT_PTR)data;
|
|
||||||
#else /* ifdef _WIN64 */
|
|
||||||
unsigned long ptr = (unsigned long)(data);
|
|
||||||
#endif /* ifdef _WIN64 */
|
|
||||||
int hash;
|
|
||||||
|
|
||||||
hash = ptr;
|
|
||||||
hash ^= ptr >> 8;
|
|
||||||
hash ^= ptr >> 16;
|
|
||||||
hash ^= ptr >> 24;
|
|
||||||
|
|
||||||
#if defined (_WIN64) || ((!defined (_WIN32)) && (LONG_BIT != 32))
|
|
||||||
hash ^= ptr >> 32;
|
|
||||||
hash ^= ptr >> 40;
|
|
||||||
hash ^= ptr >> 48;
|
|
||||||
hash ^= ptr >> 56;
|
|
||||||
#endif /* if defined (_WIN64) || ((!defined (_WIN32)) && (LONG_BIT != 32)) */
|
|
||||||
|
|
||||||
return hash & 0xFF;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_eet_free_add(Eet_Free *ef,
|
_eet_free_add(Eet_Free *ef,
|
||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
void *track;
|
eina_array_push(&ef->list, data);
|
||||||
Eina_Array_Iterator it;
|
|
||||||
unsigned int i;
|
|
||||||
int hash;
|
|
||||||
|
|
||||||
hash = _eet_free_hash(data);
|
|
||||||
|
|
||||||
EINA_ARRAY_ITER_NEXT(&ef->list[hash], i, track, it)
|
|
||||||
if (track == data)
|
|
||||||
return;
|
|
||||||
|
|
||||||
eina_array_push(&ef->list[hash], data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -2534,13 +2488,10 @@ _eet_free_del(Eet_Free *ef,
|
||||||
static void
|
static void
|
||||||
_eet_free_reset(Eet_Free *ef)
|
_eet_free_reset(Eet_Free *ef)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
if (ef->ref > 0)
|
if (ef->ref > 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (i = 0; i < EET_FREE_COUNT; ++i)
|
eina_array_clean(&ef->list);
|
||||||
eina_array_clean(&ef->list[i]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -2569,14 +2520,12 @@ _eet_freelist_free(Eet_Free_Context *context,
|
||||||
{
|
{
|
||||||
void *track;
|
void *track;
|
||||||
Eina_Array_Iterator it;
|
Eina_Array_Iterator it;
|
||||||
unsigned int j;
|
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
if (context->freelist.ref > 0)
|
if (context->freelist.ref > 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (j = 0; j < EET_FREE_COUNT; ++j)
|
EINA_ARRAY_ITER_NEXT(&context->freelist.list, i, track, it)
|
||||||
EINA_ARRAY_ITER_NEXT(&context->freelist.list[j], i, track, it)
|
|
||||||
if (track)
|
if (track)
|
||||||
{
|
{
|
||||||
if (edd)
|
if (edd)
|
||||||
|
@ -2599,14 +2548,12 @@ _eet_freelist_array_free(Eet_Free_Context *context,
|
||||||
{
|
{
|
||||||
void *track;
|
void *track;
|
||||||
Eina_Array_Iterator it;
|
Eina_Array_Iterator it;
|
||||||
unsigned int j;
|
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
if (context->freelist_array.ref > 0)
|
if (context->freelist_array.ref > 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (j = 0; j < EET_FREE_COUNT; ++j)
|
EINA_ARRAY_ITER_NEXT(&context->freelist_array.list, i, track, it)
|
||||||
EINA_ARRAY_ITER_NEXT(&context->freelist_array.list[j], i, track, it)
|
|
||||||
if (track)
|
if (track)
|
||||||
{
|
{
|
||||||
if (edd)
|
if (edd)
|
||||||
|
@ -2634,14 +2581,12 @@ _eet_freelist_list_free(Eet_Free_Context *context,
|
||||||
{
|
{
|
||||||
void *track;
|
void *track;
|
||||||
Eina_Array_Iterator it;
|
Eina_Array_Iterator it;
|
||||||
unsigned int j;
|
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
if (context->freelist_list.ref > 0)
|
if (context->freelist_list.ref > 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (j = 0; j < EET_FREE_COUNT; ++j)
|
EINA_ARRAY_ITER_NEXT(&context->freelist_list.list, i, track, it)
|
||||||
EINA_ARRAY_ITER_NEXT(&context->freelist_list.list[j], i, track, it)
|
|
||||||
if (track)
|
if (track)
|
||||||
{
|
{
|
||||||
if (edd)
|
if (edd)
|
||||||
|
@ -2662,14 +2607,12 @@ _eet_freelist_str_free(Eet_Free_Context *context,
|
||||||
{
|
{
|
||||||
void *track;
|
void *track;
|
||||||
Eina_Array_Iterator it;
|
Eina_Array_Iterator it;
|
||||||
unsigned int j;
|
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
if (context->freelist_str.ref > 0)
|
if (context->freelist_str.ref > 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (j = 0; j < EET_FREE_COUNT; ++j)
|
EINA_ARRAY_ITER_NEXT(&context->freelist_str.list, i, track, it)
|
||||||
EINA_ARRAY_ITER_NEXT(&context->freelist_str.list[j], i, track, it)
|
|
||||||
if (track)
|
if (track)
|
||||||
{
|
{
|
||||||
if (edd)
|
if (edd)
|
||||||
|
@ -2692,14 +2635,12 @@ _eet_freelist_direct_str_free(Eet_Free_Context *context,
|
||||||
{
|
{
|
||||||
void *track;
|
void *track;
|
||||||
Eina_Array_Iterator it;
|
Eina_Array_Iterator it;
|
||||||
unsigned int j;
|
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
if (context->freelist_direct_str.ref > 0)
|
if (context->freelist_direct_str.ref > 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (j = 0; j < EET_FREE_COUNT; ++j)
|
EINA_ARRAY_ITER_NEXT(&context->freelist_str.list, i, track, it)
|
||||||
EINA_ARRAY_ITER_NEXT(&context->freelist_str.list[j], i, track, it)
|
|
||||||
if (track)
|
if (track)
|
||||||
{
|
{
|
||||||
if (edd)
|
if (edd)
|
||||||
|
@ -2722,14 +2663,12 @@ _eet_freelist_hash_free(Eet_Free_Context *context,
|
||||||
{
|
{
|
||||||
void *track;
|
void *track;
|
||||||
Eina_Array_Iterator it;
|
Eina_Array_Iterator it;
|
||||||
unsigned int j;
|
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
if (context->freelist_hash.ref > 0)
|
if (context->freelist_hash.ref > 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (j = 0; j < EET_FREE_COUNT; ++j)
|
EINA_ARRAY_ITER_NEXT(&context->freelist_hash.list, i, track, it)
|
||||||
EINA_ARRAY_ITER_NEXT(&context->freelist_hash.list[j], i, track, it)
|
|
||||||
if (track)
|
if (track)
|
||||||
{
|
{
|
||||||
if (edd)
|
if (edd)
|
||||||
|
|
Loading…
Reference in New Issue