forked from enlightenment/efl
eina: improve speed of Eina_Cow.
* Use an Eina_Hash for the garbage collector list. * Turn off garbage collection on object that are unlikely to match. This patch make 1.8 as fast as 1.7 again.
This commit is contained in:
parent
a831609e63
commit
e02bb36e3a
|
@ -20,6 +20,14 @@
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_BACKTRACE
|
||||||
|
# include <execinfo.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef NVALGRIND
|
||||||
|
# include <memcheck.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "eina_config.h"
|
#include "eina_config.h"
|
||||||
#include "eina_private.h"
|
#include "eina_private.h"
|
||||||
#include "eina_log.h"
|
#include "eina_log.h"
|
||||||
|
@ -31,13 +39,6 @@
|
||||||
|
|
||||||
#include "eina_cow.h"
|
#include "eina_cow.h"
|
||||||
|
|
||||||
#ifndef NVALGRIND
|
|
||||||
# include <memcheck.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_BACKTRACE
|
|
||||||
# include <execinfo.h>
|
|
||||||
#endif
|
|
||||||
#ifdef EINA_COW_MAGIC_ON
|
#ifdef EINA_COW_MAGIC_ON
|
||||||
#define EINA_COW_MAGIC 0xDEADBEEF
|
#define EINA_COW_MAGIC 0xDEADBEEF
|
||||||
|
|
||||||
|
@ -458,7 +459,8 @@ eina_cow_write(Eina_Cow *cow,
|
||||||
EAPI void
|
EAPI void
|
||||||
eina_cow_done(Eina_Cow *cow,
|
eina_cow_done(Eina_Cow *cow,
|
||||||
const Eina_Cow_Data * const * dst,
|
const Eina_Cow_Data * const * dst,
|
||||||
const void *data)
|
const void *data,
|
||||||
|
Eina_Bool needed_gc)
|
||||||
{
|
{
|
||||||
Eina_Cow_Ptr *ref;
|
Eina_Cow_Ptr *ref;
|
||||||
Eina_Cow_GC *gc;
|
Eina_Cow_GC *gc;
|
||||||
|
@ -477,6 +479,8 @@ eina_cow_done(Eina_Cow *cow,
|
||||||
ref->writing = EINA_FALSE;
|
ref->writing = EINA_FALSE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (!needed_gc) return ;
|
||||||
|
|
||||||
/* needed if we want to make cow gc safe */
|
/* needed if we want to make cow gc safe */
|
||||||
if (ref->togc) return ;
|
if (ref->togc) return ;
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,8 @@ EAPI void *eina_cow_write(Eina_Cow *cow,
|
||||||
const Eina_Cow_Data * const *src) EINA_WARN_UNUSED_RESULT;
|
const Eina_Cow_Data * const *src) EINA_WARN_UNUSED_RESULT;
|
||||||
EAPI void eina_cow_done(Eina_Cow *cow,
|
EAPI void eina_cow_done(Eina_Cow *cow,
|
||||||
const Eina_Cow_Data * const *dst,
|
const Eina_Cow_Data * const *dst,
|
||||||
const void *data);
|
const void *data,
|
||||||
|
Eina_Bool needed_gc);
|
||||||
EAPI void eina_cow_memcpy(Eina_Cow *cow,
|
EAPI void eina_cow_memcpy(Eina_Cow *cow,
|
||||||
const Eina_Cow_Data * const *dst,
|
const Eina_Cow_Data * const *dst,
|
||||||
const Eina_Cow_Data *src);
|
const Eina_Cow_Data *src);
|
||||||
|
@ -47,7 +48,8 @@ EAPI Eina_Bool eina_cow_gc(Eina_Cow *cow);
|
||||||
Write = eina_cow_write(Cow, ((const Eina_Cow_Data**)&(Read)));
|
Write = eina_cow_write(Cow, ((const Eina_Cow_Data**)&(Read)));
|
||||||
|
|
||||||
#define EINA_COW_WRITE_END(Cow, Read, Write) \
|
#define EINA_COW_WRITE_END(Cow, Read, Write) \
|
||||||
eina_cow_done(Cow, ((const Eina_Cow_Data**)&(Read)), Write); \
|
eina_cow_done(Cow, ((const Eina_Cow_Data**)&(Read)), Write, \
|
||||||
|
EINA_TRUE); \
|
||||||
} \
|
} \
|
||||||
while (0);
|
while (0);
|
||||||
|
|
||||||
|
|
|
@ -1271,7 +1271,10 @@ extern Eina_Cow *evas_object_image_state_cow;
|
||||||
Evas_Object_Protected_State, Write)
|
Evas_Object_Protected_State, Write)
|
||||||
|
|
||||||
# define EINA_COW_STATE_WRITE_END(Obj, Write, State) \
|
# define EINA_COW_STATE_WRITE_END(Obj, Write, State) \
|
||||||
EINA_COW_WRITE_END(evas_object_state_cow, Obj->State, Write)
|
eina_cow_done(evas_object_state_cow, ((const Eina_Cow_Data**)&(Obj->State)), \
|
||||||
|
Write, EINA_FALSE); \
|
||||||
|
} \
|
||||||
|
while (0);
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
/*****************************************/
|
/*****************************************/
|
||||||
|
|
|
@ -58,7 +58,7 @@ START_TEST(eina_cow_bad)
|
||||||
fail_if(write == NULL || write == &default_value);
|
fail_if(write == NULL || write == &default_value);
|
||||||
|
|
||||||
write->i = 7;
|
write->i = 7;
|
||||||
eina_cow_done(cow, (const Eina_Cow_Data**) &cur, write);
|
eina_cow_done(cow, (const Eina_Cow_Data**) &cur, write, EINA_FALSE);
|
||||||
fail_if(cur->i != 7 || default_value.i != 42);
|
fail_if(cur->i != 7 || default_value.i != 42);
|
||||||
|
|
||||||
#ifdef EINA_COW_MAGIC
|
#ifdef EINA_COW_MAGIC
|
||||||
|
@ -67,7 +67,7 @@ START_TEST(eina_cow_bad)
|
||||||
|
|
||||||
eina_log_print_cb_set(_eina_test_log, &over_commit);
|
eina_log_print_cb_set(_eina_test_log, &over_commit);
|
||||||
/* Testing over commit */
|
/* Testing over commit */
|
||||||
eina_cow_done(cow, (const Eina_Cow_Data**) &cur, write);
|
eina_cow_done(cow, (const Eina_Cow_Data**) &cur, write, EINA_FALSE);
|
||||||
fail_if(!over_commit);
|
fail_if(!over_commit);
|
||||||
|
|
||||||
write = eina_cow_write(cow, (const Eina_Cow_Data**) &cur);
|
write = eina_cow_write(cow, (const Eina_Cow_Data**) &cur);
|
||||||
|
@ -106,7 +106,7 @@ START_TEST(eina_cow)
|
||||||
fail_if(write == NULL || write == &default_value);
|
fail_if(write == NULL || write == &default_value);
|
||||||
|
|
||||||
write->i = 7;
|
write->i = 7;
|
||||||
eina_cow_done(cow, (const Eina_Cow_Data**) &cur, write);
|
eina_cow_done(cow, (const Eina_Cow_Data**) &cur, write, EINA_TRUE);
|
||||||
fail_if(cur->i != 7 || prev->i != 0);
|
fail_if(cur->i != 7 || prev->i != 0);
|
||||||
|
|
||||||
eina_cow_memcpy(cow,
|
eina_cow_memcpy(cow,
|
||||||
|
@ -119,7 +119,7 @@ START_TEST(eina_cow)
|
||||||
fail_if(write == NULL || write == &default_value);
|
fail_if(write == NULL || write == &default_value);
|
||||||
|
|
||||||
write->i = 42; write->c = 5;
|
write->i = 42; write->c = 5;
|
||||||
eina_cow_done(cow, (const Eina_Cow_Data**) &cur, write);
|
eina_cow_done(cow, (const Eina_Cow_Data**) &cur, write, EINA_TRUE);
|
||||||
fail_if(cur->i != 42 || cur->c != 5 ||
|
fail_if(cur->i != 42 || cur->c != 5 ||
|
||||||
prev->i != 7 || prev->c != 42 ||
|
prev->i != 7 || prev->c != 42 ||
|
||||||
default_value.c != 42 || default_value.i != 0);
|
default_value.c != 42 || default_value.i != 0);
|
||||||
|
@ -129,7 +129,7 @@ START_TEST(eina_cow)
|
||||||
|
|
||||||
write = eina_cow_write(cow, (const Eina_Cow_Data**) &cur);
|
write = eina_cow_write(cow, (const Eina_Cow_Data**) &cur);
|
||||||
write->i = 7; write->c = 42;
|
write->i = 7; write->c = 42;
|
||||||
eina_cow_done(cow, (const Eina_Cow_Data**) &cur, write);
|
eina_cow_done(cow, (const Eina_Cow_Data**) &cur, write, EINA_TRUE);
|
||||||
|
|
||||||
fail_if(eina_cow_gc(cow) == EINA_FALSE);
|
fail_if(eina_cow_gc(cow) == EINA_FALSE);
|
||||||
fail_if(cur != prev);
|
fail_if(cur != prev);
|
||||||
|
|
Loading…
Reference in New Issue