From 784b6a8f1dd611e2f89dfeabc8eeb55c3b604c87 Mon Sep 17 00:00:00 2001 From: subhransu mohanty Date: Thu, 8 Aug 2019 09:19:36 +0900 Subject: [PATCH] efl/tracing: refactor tracing in efl to support different tracing backend. The code will be cleaner with only the Trace call without any ifdef mess. Easy to change the trace profilier by changing the trace backend. if disabled won't add any code to efl. Change-Id: I2b8a1d00f8470b904703c23ffd17aac0ab3eeaaf --- meson.build | 1 + meson_options.txt | 7 +++ src/lib/ecore_evas/ecore_evas.c | 18 +++---- src/lib/ecore_evas/ecore_evas_private.h | 4 -- src/lib/edje/edje_cache.c | 9 +++- src/lib/edje/edje_message_queue.c | 13 ++++- src/lib/eina/eina_evlog.c | 8 +-- src/lib/eina/meson.build | 1 + src/lib/elementary/Elementary.h | 4 -- src/lib/elementary/efl_ui_win.c | 21 +++++--- src/lib/elementary/elm_main.c | 33 +++++++----- src/lib/evas/canvas/evas_font_dir.c | 11 ++++ src/lib/evas/canvas/evas_render.c | 8 +++ tracing/efl_tracing.h | 94 +++++++++++++++++++++++++++++++++ tracing/meson.build | 23 ++++++++ 15 files changed, 206 insertions(+), 49 deletions(-) create mode 100644 tracing/efl_tracing.h create mode 100644 tracing/meson.build diff --git a/meson.build b/meson.build index ec29f9d..3cf822a 100644 --- a/meson.build +++ b/meson.build @@ -235,6 +235,7 @@ endif subdir('header_checks') subdir('po') +subdir('tracing') if get_option('wl') == true subdir(join_paths('src', 'wayland_protocol')) diff --git a/meson_options.txt b/meson_options.txt index f7c2504..223e535 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -384,4 +384,11 @@ option('tbm', type: 'boolean', value: false, description: 'tbm engine' +) + +option('trace', + type : 'combo', + choices : ['ttrace', 'vtune', 'none'], + value : 'none', + description : 'Support Tracing in Efl' ) \ No newline at end of file diff --git a/src/lib/ecore_evas/ecore_evas.c b/src/lib/ecore_evas/ecore_evas.c index 8b9d359..4db4cac 100644 --- a/src/lib/ecore_evas/ecore_evas.c +++ b/src/lib/ecore_evas/ecore_evas.c @@ -37,6 +37,8 @@ #include "ecore_private.h" +#include "efl_tracing.h" + #ifndef O_BINARY # define O_BINARY 0 #endif @@ -4937,26 +4939,20 @@ ecore_evas_wayland_shm_new(const char *disp_name, unsigned int parent, int x, int y, int w, int h, Eina_Bool frame) { //TIZEN_ONLY(20160628): Add Performance log for cold booting -#ifdef ENABLE_TTRACE - traceBegin(TTRACE_TAG_EFL, "ecore_evas_wayland_shm_new"); -#endif + traceTaskStart("ecore_evas_wayland_shm_new"); // Ecore_Evas *ee; Ecore_Evas *(*new)(const char *, Ecore_Window, int, int, int, int, Eina_Bool); Eina_Module *m = _ecore_evas_engine_load("wayland"); //TIZEN_ONLY(20160628): Add Performance log for cold booting -#ifdef ENABLE_TTRACE - if (!m) traceEnd(TTRACE_TAG_EFL); -#endif + if (!m) traceTaskEnd(); // EINA_SAFETY_ON_NULL_RETURN_VAL(m, NULL); new = eina_module_symbol_get(m, "ecore_evas_wayland_shm_new_internal"); //TIZEN_ONLY(20160628): Add Performance log for cold booting -#ifdef ENABLE_TTRACE - if (!new) traceEnd(TTRACE_TAG_EFL); -#endif + if (!new) traceTaskEnd(); // EINA_SAFETY_ON_NULL_RETURN_VAL(new, NULL); @@ -4969,9 +4965,7 @@ ecore_evas_wayland_shm_new(const char *disp_name, unsigned int parent, return NULL; } //TIZEN_ONLY(20160628): Add Performance log for cold booting -#ifdef ENABLE_TTRACE - traceEnd(TTRACE_TAG_EFL); -#endif + traceTaskEnd(); // return ee; } diff --git a/src/lib/ecore_evas/ecore_evas_private.h b/src/lib/ecore_evas/ecore_evas_private.h index fe32f6d..42041b2 100644 --- a/src/lib/ecore_evas/ecore_evas_private.h +++ b/src/lib/ecore_evas/ecore_evas_private.h @@ -59,10 +59,6 @@ EAPI extern int _ecore_evas_log_dom; #endif #define CRI(...) EINA_LOG_DOM_CRIT(_ecore_evas_log_dom, __VA_ARGS__) -#ifdef ENABLE_TTRACE -#include -#endif - #define PORTRAIT_CHECK(r) \ ((r == 0) || (r == 180)) diff --git a/src/lib/edje/edje_cache.c b/src/lib/edje/edje_cache.c index 4c2d8d8..6d2063f 100644 --- a/src/lib/edje/edje_cache.c +++ b/src/lib/edje/edje_cache.c @@ -1,5 +1,7 @@ #include "edje_private.h" +#include "efl_tracing.h" + Eina_Hash *_edje_file_hash = NULL; static int _edje_file_cache_size = 16; @@ -182,6 +184,8 @@ _edje_file_coll_open(Edje_File *edf, const char *coll) id = ce->id; if (id < 0) return NULL; + traceTaskDataStart("edje_coll_open", coll); + edje_cache_emp_alloc(ce); snprintf(buf, sizeof(buf), "edje/collections/%i", id); edc = eet_data_read(edf->ef, _edje_edd_edje_part_collection, buf); @@ -274,7 +278,7 @@ _edje_file_coll_open(Edje_File *edf, const char *coll) EDJE_LOAD_BUILD_TABLE(nocmp, edc, i, pr); } } - + traceTaskEnd(); return edc; } @@ -298,6 +302,8 @@ _edje_file_open(const Eina_File *f, int *error_ret, time_t mtime, Eina_Bool coll void *mapping; size_t mapping_size; + traceTaskDataStart("edje_file_open", eina_file_filename_get(f)); + ef = eet_mmap(f); if (!ef) { @@ -387,6 +393,7 @@ _edje_file_open(const Eina_File *f, int *error_ret, time_t mtime, Eina_Bool coll if (sc->name) eina_hash_direct_add(edf->size_hash, sc->name, sc); + traceTaskEnd(); return edf; } diff --git a/src/lib/edje/edje_message_queue.c b/src/lib/edje/edje_message_queue.c index 020f89b..a82122a 100644 --- a/src/lib/edje/edje_message_queue.c +++ b/src/lib/edje/edje_message_queue.c @@ -1,5 +1,7 @@ #include "edje_private.h" +#include "efl_tracing.h" + static void _edje_message_propagate_send(Edje *ed, Edje_Queue queue, Edje_Message_Type type, int id, void *emsg, Eina_Bool prop); static int _injob = 0; @@ -271,11 +273,20 @@ _efl_canvas_layout_efl_layout_signal_signal_process(Eo *obj, Edje *ed, Eina_Bool Evas_Object *o; if (ed->delete_me) return; + + traceTaskStart("edje_signal_process"); + _edje_object_message_signal_process_do(obj, ed); - if (!recurse) return; + if (!recurse) + { + traceTaskEnd(); + return; + } EINA_LIST_FOREACH(ed->subobjs, l, o) efl_layout_signal_process(o, EINA_TRUE); + + traceTaskEnd(); } static Eina_Bool diff --git a/src/lib/eina/eina_evlog.c b/src/lib/eina/eina_evlog.c index dd3c45b..cc77f12 100644 --- a/src/lib/eina/eina_evlog.c +++ b/src/lib/eina/eina_evlog.c @@ -29,11 +29,7 @@ #include "eina_evlog.h" #include "eina_debug.h" -// TIZEN_ONLY(20160401): TTRACE -#ifdef ENABLE_TTRACE -#include -#endif -// TIZEN_ONLY(20160401): TTRACE +#include "efl_tracing.h" #if defined(__APPLE__) && defined(__MACH__) # include @@ -164,7 +160,7 @@ eina_evlog(const char *event, void *obj, double srctime, const char *detail) unsigned short detail_offset, event_size; // TIZEN_ONLY(20160401): TTRACE -#ifdef ENABLE_TTRACE +#ifdef TTRACE_PROFILER #ifndef TIZEN_PROFILE_TV if(!strncmp(event, "+", 1)) traceBegin(TTRACE_TAG_GRAPHICS, event + 1); diff --git a/src/lib/eina/meson.build b/src/lib/eina/meson.build index a1b4383..b73ba51 100644 --- a/src/lib/eina/meson.build +++ b/src/lib/eina/meson.build @@ -1,4 +1,5 @@ eina_deps = [dl] +eina_deps += tracing_deps eina_pub_deps = [thread_dep] if sys_windows == true diff --git a/src/lib/elementary/Elementary.h b/src/lib/elementary/Elementary.h index 9c4aabd..72af897 100644 --- a/src/lib/elementary/Elementary.h +++ b/src/lib/elementary/Elementary.h @@ -83,10 +83,6 @@ #include #endif -#ifdef ENABLE_TTRACE -#include -#endif - #ifdef EAPI # undef EAPI #endif diff --git a/src/lib/elementary/efl_ui_win.c b/src/lib/elementary/efl_ui_win.c index 4663bb2..cb54209 100644 --- a/src/lib/elementary/efl_ui_win.c +++ b/src/lib/elementary/efl_ui_win.c @@ -18,6 +18,8 @@ #include #include +#include "efl_tracing.h" + #include "elm_priv.h" #include "elm_widget_menu.h" #ifdef HAVE_ELEMENTARY_WL2 @@ -8609,6 +8611,8 @@ _elm_win_bg_must_swallow(Efl_Ui_Win_Data *sd) void _elm_win_standard_init(Eo *obj) { + traceTaskStart("win_standard_init"); + /* Support for elm_util_win_standard_add() and Efl.Ui.Win.Standard */ Efl_Ui_Win_Data *sd = efl_data_scope_get(obj, MY_CLASS); @@ -8639,6 +8643,8 @@ _elm_win_standard_init(Eo *obj) } _elm_win_frame_style_update(sd, 0, 1); + + traceTaskEnd(); } static Eina_Bool @@ -10756,9 +10762,7 @@ EAPI Evas_Object * elm_win_add(Evas_Object *parent, const char *name, Elm_Win_Type type) { //TIZEN_ONLY(20160628): Add Performance log for cold booting -#ifdef ENABLE_TTRACE - traceBegin(TTRACE_TAG_EFL, "elm_win_add"); -#endif + traceTaskStart("elm_win_add"); // const Efl_Class *klass = EFL_UI_WIN_LEGACY_CLASS; @@ -10802,7 +10806,7 @@ elm_win_add(Evas_Object *parent, const char *name, Elm_Win_Type type) else efl_canvas_object_paragraph_direction_set(tmp, EVAS_BIDI_DIRECTION_LTR); /* END */ - + traceTaskEnd(); return tmp; } } @@ -10814,9 +10818,7 @@ elm_win_add(Evas_Object *parent, const char *name, Elm_Win_Type type) efl_ui_win_type_set(efl_added, type)); //TIZEN_ONLY(20160628): Add Performance log for cold booting -#ifdef ENABLE_TTRACE - traceEnd(TTRACE_TAG_EFL); -#endif + traceTaskEnd(); // return obj; } @@ -10836,6 +10838,8 @@ elm_win_util_standard_add(const char *name, const char *title) { Evas_Object *win; + traceTaskStart("win_standard_add"); + // TIZEN_ONLY(20180518): apply precreated window win = elm_win_add(NULL, name, ELM_WIN_BASIC); if (!win) return NULL; @@ -10850,6 +10854,9 @@ elm_win_util_standard_add(const char *name, const char *title) *////// _elm_win_standard_init(win); + + traceTaskEnd(); + return win; } diff --git a/src/lib/elementary/elm_main.c b/src/lib/elementary/elm_main.c index c1f754c..9219c82 100644 --- a/src/lib/elementary/elm_main.c +++ b/src/lib/elementary/elm_main.c @@ -19,6 +19,8 @@ #include +#include "efl_tracing.h" + #include "eina_internal.h" #include "ecore_internal.h" @@ -426,22 +428,15 @@ static const char *bcargv[] = { "exe" }; EAPI int elm_init(int argc, char **argv) { -//TIZEN_ONLY(20160628): Add Performance log for cold booting -#ifdef ENABLE_TTRACE - traceBegin(TTRACE_TAG_EFL, "elm_init"); -#endif - // _elm_init_count++; if (_elm_init_count > 1) { -//TIZEN_ONLY(20160628): Add Performance log for cold booting -#ifdef ENABLE_TTRACE - traceEnd(TTRACE_TAG_EFL); -#endif - // return _elm_init_count; } + //TIZEN_ONLY(20160628): Add Performance log for cold booting + traceTaskStart("elm_init"); + // EINA_SAFETY_ON_FALSE_RETURN_VAL(elm_quicklaunch_init(argc, argv ? argv : (char**) bcargv), --_elm_init_count); EINA_SAFETY_ON_FALSE_GOTO(elm_quicklaunch_sub_init(argc, argv ? argv : (char**) bcargv), shutdown_ql); @@ -477,11 +472,10 @@ elm_init(int argc, char **argv) _elm_startup_time = _efl_startup_time; _efl_ui_theme_apply_error_init(); -//TIZEN_ONLY(20160628): Add Performance log for cold booting -#ifdef ENABLE_TTRACE - traceEnd(TTRACE_TAG_EFL); -#endif + //TIZEN_ONLY(20160628): Add Performance log for cold booting + traceTaskEnd(); // + return _elm_init_count; shutdown_ql: elm_quicklaunch_shutdown(); @@ -821,6 +815,9 @@ elm_quicklaunch_init(int argc EINA_UNUSED, { _elm_ql_init_count++; if (_elm_ql_init_count > 1) return _elm_ql_init_count; + + traceTaskStart("elm_quicklaunch_init"); + _use_build_config = !!getenv("EFL_RUN_IN_TREE"); EINA_SAFETY_ON_FALSE_GOTO(eina_init(), fail_eina); _elm_log_dom = eina_log_domain_register("elementary", EINA_COLOR_LIGHTBLUE); @@ -878,6 +875,8 @@ elm_quicklaunch_init(int argc EINA_UNUSED, eina_log_timing(_elm_log_dom, EINA_LOG_STATE_STOP, EINA_LOG_STATE_INIT); + traceTaskEnd(); + if (quicklaunch_on) _elm_init_count++; return _elm_ql_init_count; @@ -911,6 +910,9 @@ elm_quicklaunch_sub_init(int argc, { _elm_sub_init_count++; if (_elm_sub_init_count > 1) return _elm_sub_init_count; + + traceTaskStart("elm_quicklaunch_sub_init"); + _elm_config_init(); if (!quicklaunch_on) @@ -926,6 +928,9 @@ elm_quicklaunch_sub_init(int argc, _elm_prefs_initted = _elm_prefs_init(); EINA_SAFETY_ON_FALSE_GOTO(_elm_ews_wm_init(), ql_sub_ews);; } + + traceTaskEnd(); + return _elm_sub_init_count; ql_sub_ews: if (_elm_prefs_initted) _elm_prefs_shutdown(); diff --git a/src/lib/evas/canvas/evas_font_dir.c b/src/lib/evas/canvas/evas_font_dir.c index 55c18dd..e6af219 100644 --- a/src/lib/evas/canvas/evas_font_dir.c +++ b/src/lib/evas/canvas/evas_font_dir.c @@ -15,6 +15,8 @@ #include "evas_font.h" +#include "efl_tracing.h" + /* General types - used for script type chceking */ #define OPAQUE_TYPE(type) struct __##type { int a; }; \ typedef struct __##type type @@ -134,10 +136,14 @@ evas_font_init(void) Eina_List *l; char *path; + traceTaskStart("font_config_init"); + fc_config = FcInitLoadConfigAndFonts(); EINA_LIST_FOREACH(global_font_path, l, path) FcConfigAppFontAddDir(fc_config, (const FcChar8 *) path); + + traceTaskEnd(); } #endif } @@ -700,6 +706,8 @@ evas_font_load(const Eina_List *font_paths, int hinting, Evas_Font_Description * } } + traceTaskDataStart("font_load", fdesc->name); + #ifdef HAVE_FONTCONFIG if (found_fd) { @@ -976,6 +984,9 @@ evas_font_load(const Eina_List *font_paths, int hinting, Evas_Font_Description * if (font) evas_common_font_hinting_set((RGBA_Font *)font, hinting); + + traceTaskEnd(); + return font; } diff --git a/src/lib/evas/canvas/evas_render.c b/src/lib/evas/canvas/evas_render.c index 596bca8..768bebd 100644 --- a/src/lib/evas/canvas/evas_render.c +++ b/src/lib/evas/canvas/evas_render.c @@ -15,6 +15,8 @@ //#define REND_DBG 1 #define STDOUT_DBG +#include "efl_tracing.h" + #ifdef REND_DBG static FILE *dbf = NULL; static int __RD_level = 0; @@ -3268,6 +3270,8 @@ evas_render_updates_internal(Evas *eo_e, double start_time = _time_get(); #endif + traceFrameStart(); + evas_render_pre(eo_e, evas); _evas_planes(e); @@ -3771,6 +3775,8 @@ evas_render_updates_internal(Evas *eo_e, e->inside_post_render = EINA_FALSE; eina_spinlock_release(&(e->render.lock)); if (post.updated_area) eina_list_free(post.updated_area); + + traceFrameEnd(); } RD(0, "---]\n"); @@ -3891,6 +3897,8 @@ evas_render_wakeup(Evas *eo_e) #ifdef EVAS_RENDER_DEBUG_TIMING _accumulate_time(0, EINA_TRUE); #endif + + traceFrameEnd(); } static void diff --git a/tracing/efl_tracing.h b/tracing/efl_tracing.h new file mode 100644 index 0000000..44c7521 --- /dev/null +++ b/tracing/efl_tracing.h @@ -0,0 +1,94 @@ +#pragma once + +#ifdef HAVE_CONFIG_H +# include "config.h" +#else +# define EINA_UNUSED +#endif + +#ifdef TTRACE_PROFILER + +#include + +static inline void _ttrace_append_domain(const char *name, const char *data) +{ + char buf[500]; + + if (data) + { + sprintf(buf,"%s::%s", name,data); + traceBegin(TTRACE_TAG_EFL, buf); + } + else + traceBegin(TTRACE_TAG_EFL, name); +} + +#define traceFrameStart() traceBegin(TTRACE_TAG_EFL, "Frame") + +#define traceFrameEnd() traceEnd(TTRACE_TAG_EFL) + +#define traceTaskDataStart(name, data) _ttrace_append_domain(name, data) + +#define traceTaskStart(name) traceBegin(TTRACE_TAG_EFL, name); + +#define traceTaskEnd() traceEnd(TTRACE_TAG_EFL); + +#elif VTUNE_PROFILER + +#include + +static __itt_domain* _vtune_efl_domain = NULL; + +static inline void _vtune_task_start(const char *name) +{ + if (!_vtune_efl_domain) _vtune_efl_domain = __itt_domain_create("EFL"); + + __itt_task_begin(_vtune_efl_domain, __itt_null, __itt_null, + __itt_string_handle_create(name)); +} + +static inline void _vtune_append_domain(const char *name, const char *data) +{ + char buf[500]; + + if (!_vtune_efl_domain) _vtune_efl_domain = __itt_domain_create("EFL"); + + if (data) + sprintf(buf,"%s::%s", name,data); + else + sprintf(buf,"%s", name); + + __itt_task_begin(_vtune_efl_domain, __itt_null, __itt_null, + __itt_string_handle_create(buf)); +} + +static inline void _vtune_frame_start() +{ + if (!_vtune_efl_domain) _vtune_efl_domain = __itt_domain_create("EFL"); + + __itt_frame_begin_v3(_vtune_efl_domain, NULL); +} + +#define traceFrameStart() _vtune_frame_start(); + +#define traceFrameEnd() __itt_frame_end_v3(_vtune_efl_domain, NULL) + +#define traceTaskDataStart(name, data) _vtune_append_domain(name, data) + +#define traceTaskStart(name) _vtune_task_start(name) + +#define traceTaskEnd() __itt_task_end(_vtune_efl_domain) + +#else + +#define traceTaskDataStart(name, data) + +#define traceTaskStart(name) + +#define traceTaskEnd() + +#define traceFrameStart() + +#define traceFrameEnd() + +#endif \ No newline at end of file diff --git a/tracing/meson.build b/tracing/meson.build new file mode 100644 index 0000000..cdddf90 --- /dev/null +++ b/tracing/meson.build @@ -0,0 +1,23 @@ +config_dir += include_directories('.') + +tracing_deps = [] + +if (get_option('trace') == 'ttrace') + config_h.set10('TTRACE_PROFILER', true) + tracing_deps = dependency('ttrace') +elif (get_option('trace') == 'vtune') + config_h.set10('VTUNE_PROFILER', true) + vtune_dep = dependency('ittnotify' , required:false) + if (vtune_dep.found()) + tracing_deps += vtune_dep + else + cc = meson.get_compiler('cpp') + lib_itt = cc.find_library('ittnotify', + dirs : ['/opt/intel/system_studio_2019/vtune_amplifier_2019/lib64/']) + lib_itt_dep = declare_dependency ( + include_directories : include_directories('/opt/intel/system_studio_2019/vtune_amplifier_2019/include'), + dependencies: lib_itt + ) + tracing_deps += lib_itt_dep + endif +endif -- 2.7.4