eo - make eo id table TLS private data for thread safety and speed
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>
Wed, 7 Sep 2016 08:53:33 +0000 (17:53 +0900)
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>
Wed, 7 Sep 2016 09:17:10 +0000 (18:17 +0900)
commit09f19c3c73b73eeee4201bb462bad9f2b5276409
tree04e81f8637c222ae7f2eed087272dedfe8e53773
parent59bdf3461ce18f48bba0d315392a536b3778c368
eo - make eo id table TLS private data for thread safety and speed

This moved all the eoid tables, eoid lookup caches, generation count
information ad eo_isa cache into a TLS segment of memory that is
thread private. There is also a shared domain for EO objects that all
threads can access, but it has an added cost of a lock. This means
objects accessed outside the thread they were created in cannot be
accessed by another thread unless they are adopted in temporarily, or
create4d with the shared domain active at the time of creation. child
objects will use their parent object domain if created with a parent
object passed in. If you were accessing EO (EFL) objects across threads
before then this will actually now cause your code to fail as it was
invalid before to do this as no actual objects were threadsafe in EFL,
so this will force things to "fail early".
ecore_thread_main_loop_begin() and end() still work as this uses the
eo domain adoption features to temporarily adopt a domain during this
section and then return it when done.

This returns speed back to eo brining the overhead in my tests of
lookup for the elm genlist autobounce test in elementary from about
5-7% down to 2.5-2.6%. A steep drop.

This does not mean everything is perfect. Still to do are:

1. Tests in the test suite
2. Some API's to help for sending objects from thread to thread
3. Make the eo call cache TLS data to make it also safe
4. Look at other locks in eo and probably move them to TLS data
5. Make eo resolve and call wrappers that call the real method func do
   recursive mutex wrapping of the given object IF it is a shared object
   to provide threadsafety transparently for shared objects (but adding
   some overhead as a result)
6. Test test est, and that is why this commit is going in now for wider
   testing
7. Decide how to make this work with sending IPC (between threads)
8. Deciding what makes an object sendable (a sendable property in base?)
9. Deciding what makes an object shareable (a sharable property in base?)
src/lib/ecore/ecore.c
src/lib/eo/Eo.h
src/lib/eo/eo.c
src/lib/eo/eo_base_class.c
src/lib/eo/eo_private.h
src/lib/eo/eo_ptr_indirection.c
src/lib/eo/eo_ptr_indirection.h
src/lib/eo/eo_ptr_indirection.x