Cool. :) I have to admit though, the reason why TLS is so slow is beyond me. I would expect the kernel to just update a var as part of the context switch (same way the stack is changed), and then just look up variables from that table, which translates to one indirection no locks. Not this crazy overhead. Also, there are surely easier ways for libc to deal with it. Obviously this would be a horrible hack that shouldn't use in production, but for example just checking the stack address range is already a much faster way of figuring out which thread you are in and where to fetch data from. You could for example just store all the vars at specific offsets at the end of the stack. I also have a patch in my branch to use the "__thread" specificier when available, which will hopefully result in this improving with time as implementations improve.
I still need to figure out how to improve _eo_call_resolve. :( I have a way to improve it by additional 5%, I think, though it's a bit ugly (and again, breaks ABI). I'll discuss it further tomorrow, Sunday or Monday, and we can see if it's worth the hassle. -- Tom. On Fri, Oct 16, 2015 at 5:02 PM, Cedric BAIL <cedric.b...@free.fr> wrote: > Le 16 oct. 2015 08:43, "Tom Hacohen" <t...@osg.samsung.com> a écrit : > > On 16/10/15 16:22, Tom Hacohen wrote: > > > On 16/10/15 15:53, Cedric BAIL wrote: > > >> Le 16 oct. 2015 6:53 AM, "Tom Hacohen" <t...@stosb.com> a écrit : > > >>> > > >>> tasn pushed a commit to branch master. > > >>> > > >>> > > >> > > http://git.enlightenment.org/core/efl.git/commit/?id=b61556aa87ad134fe04fbdc8f953bd98d941a18e > > >>> > > >>> commit b61556aa87ad134fe04fbdc8f953bd98d941a18e > > >>> Author: Tom Hacohen <t...@stosb.com> > > >>> Date: Fri Oct 16 13:01:01 2015 +0100 > > >>> > > >>> Eo: Move mainloop checks inside Eo. > > >>> > > >>> This breaks ABI in a harmless way, and it will give us the > ability to > > >>> drastically improve Eo in the future without breaking ABI > again, thus > > >>> allowing us to declare Eo stable for this release if we choose > to. > > >> > > >> Checking if a code is running in the main loop is costly. It is as > costly > > >> as a tls access in my test. The purpose was to reuse the value. I > don't > > >> know if the code evolved to a point we couldn't reuse the value > anymore, > > >> but did you check any performance impact ? > > > > > > See the code, it was already used only once, so it was not actually > > > reused at all. Since this is code in the header, this could have never > > > been changed without breaking ABI anyway, which means this change > > > actually has 0 performance impact. Well, actually, it is a slight > > > positive impact, as you now pass less things on the stack and the "code > > > size" is a bit smaller. > > > > > > I'm working on a follow up patch that improves speed drastically that > > > actually caches some values among calls. I already finished and it's > > > pretty awesome, but I need to just see if I can improve it a bit > further > > > before I push. I guess I can puhs now and worst can improve in a > > > separate patch. > > > > There you go, now it's in. This should be the end of this series of ABI > > breaks and hopefully the end of ABI breaks in Eo in general. This was > > requested by Carsten so all of the ABI breaks that lead to significant > > performance improvements will be in now. > > > > I have a few more improvements in my branch, and I think I reach a total > > of around 30% speed improvement with my whole patch series. I plan on > > maybe doing a quick write up with some graphs and more info soon. > > Seems you addressed all my worry already. That's all great news ! Cool job > ! > > Have fun, > Cedric > > > -- > > Tom > > > > > > > > > > > -- > > > Tom. > > > > > >> > > >>> --- > > >>> src/lib/eo/Eo.h | 5 ++--- > > >>> src/lib/eo/eo.c | 7 +++---- > > >>> 2 files changed, 5 insertions(+), 7 deletions(-) > > >>> > > >>> diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h > > >>> index 9bfc060..a50a327 100644 > > >>> --- a/src/lib/eo/Eo.h > > >>> +++ b/src/lib/eo/Eo.h > > >>> @@ -467,11 +467,10 @@ EAPI extern Eo_Hook_Call eo_hook_call_post; > > >>> // cache OP id, get real fct and object data then do the call > > >>> #define EO_FUNC_COMMON_OP(Name, DefRet) > \ > > >>> Eo_Op_Call_Data ___call; > \ > > >>> - Eina_Bool ___is_main_loop = eina_main_loop_is(); > \ > > >>> static Eo_Op ___op = EO_NOOP; > \ > > >>> if (___op == EO_NOOP) > \ > > >>> ___op = _eo_api_op_id_get(EO_FUNC_COMMON_OP_FUNC(Name)); \ > > >>> - if (!_eo_call_resolve(#Name, ___op, &___call, ___is_main_loop, > > >> __FILE__, __LINE__)) return DefRet; \ > > >>> + if (!_eo_call_resolve(#Name, ___op, &___call, __FILE__, > __LINE__)) > > >> return DefRet; \ > > >>> _Eo_##Name##_func _func_ = (_Eo_##Name##_func) ___call.func; > \ > > >>> > > >>> // to define an EAPI function > > >>> @@ -538,7 +537,7 @@ EAPI extern Eo_Hook_Call eo_hook_call_post; > > >>> EAPI Eo_Op _eo_api_op_id_get(const void *api_func); > > >>> > > >>> // gets the real function pointer and the object data > > >>> -EAPI Eina_Bool _eo_call_resolve(const char *func_name, const Eo_Op > op, > > >> Eo_Op_Call_Data *call, Eina_Bool is_main_loop, const char *file, int > line); > > >>> +EAPI Eina_Bool _eo_call_resolve(const char *func_name, const Eo_Op > op, > > >> Eo_Op_Call_Data *call, const char *file, int line); > > >>> > > >>> // start of eo_do barrier, gets the object pointer and ref it, put > it on > > >> the stask > > >>> EAPI Eina_Bool _eo_do_start(const Eo *obj, const Eo_Class > *cur_klass, > > >> Eina_Bool is_super, const char *file, const char *func, int line); > > >>> diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c > > >>> index 8006318..5f56dfa 100644 > > >>> --- a/src/lib/eo/eo.c > > >>> +++ b/src/lib/eo/eo.c > > >>> @@ -491,10 +491,9 @@ _eo_do_internal(const Eo *eo_id, const Eo_Class > > >> *cur_klass_id, > > >>> EAPI Eina_Bool > > >>> _eo_do_start(const Eo *eo_id, const Eo_Class *cur_klass_id, > Eina_Bool > > >> is_super, const char *file EINA_UNUSED, const char *func EINA_UNUSED, > int > > >> line EINA_UNUSED) > > >>> { > > >>> - Eina_Bool is_main_loop = eina_main_loop_is(); > > >>> Eina_Bool ret = EINA_TRUE; > > >>> Eo_Stack_Frame *fptr, *pfptr; > > >>> - Eo_Call_Stack *stack = _eo_call_stack_get(is_main_loop); > > >>> + Eo_Call_Stack *stack = _eo_call_stack_get(eina_main_loop_is()); > > >>> > > >>> if (stack->frame_ptr == stack->last_frame) > > >>> _eo_call_stack_resize(stack, EINA_TRUE); > > >>> @@ -543,14 +542,14 @@ _eo_do_end(void) > > >>> } > > >>> > > >>> EAPI Eina_Bool > > >>> -_eo_call_resolve(const char *func_name, const Eo_Op op, > Eo_Op_Call_Data > > >> *call, Eina_Bool is_main_loop, const char *file, int line) > > >>> +_eo_call_resolve(const char *func_name, const Eo_Op op, > Eo_Op_Call_Data > > >> *call, const char *file, int line) > > >>> { > > >>> Eo_Stack_Frame *fptr; > > >>> const _Eo_Class *klass; > > >>> const op_type_funcs *func; > > >>> Eina_Bool is_obj; > > >>> > > >>> - fptr = _eo_call_stack_get(is_main_loop)->frame_ptr; > > >>> + fptr = _eo_call_stack_get(eina_main_loop_is())->frame_ptr; > > >>> > > >>> if (EINA_UNLIKELY(!fptr->o.obj)) > > >>> return EINA_FALSE; > > >>> > > >>> -- > > >>> > > >>> > > >>> > > >> > > ------------------------------------------------------------------------------ > > >> _______________________________________________ > > >> enlightenment-devel mailing list > > >> enlightenment-devel@lists.sourceforge.net > > >> https://lists.sourceforge.net/lists/listinfo/enlightenment-devel > > >> > > > > > > > > > > > ------------------------------------------------------------------------------ > > > _______________________________________________ > > > enlightenment-devel mailing list > > > enlightenment-devel@lists.sourceforge.net > > > https://lists.sourceforge.net/lists/listinfo/enlightenment-devel > > > > > > > > > > > ------------------------------------------------------------------------------ > > _______________________________________________ > > enlightenment-devel mailing list > > enlightenment-devel@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/enlightenment-devel > > ------------------------------------------------------------------------------ > _______________________________________________ > enlightenment-devel mailing list > enlightenment-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/enlightenment-devel > ------------------------------------------------------------------------------ _______________________________________________ enlightenment-devel mailing list enlightenment-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-devel