From: Daniel Santos Subject: [PATCH] Fix performance problem in debug tracing Message-Id: <1440803579-17342-1-git-send-email-daniel.santos@pobox.com> Date: Fri, 28 Aug 2015 18:12:59 -0500 Currently, if any classes are passed to WINEDEBUG (nb_debug_options > 0) then the initial lazy-init call to __wine_dbg_get_channel_flags() never sets the flags in the struct __wine_debug_channel in the object file, resulting in all 45k trace calls in wine making a function call, running bsearch on debug_options with string compare, etc. This patch fixes the problem by setting the flags in all cases where __wine_dbg_get_channel_flags() is called and flags has the __WINE_DBCL_INIT bit set. The only possibly negative consequence that I can see is that __wine_dbg_set_channel_flags() will be ineffective if an initial call has been made from a tracepoint in a given object file, since the struct __wine_debug_channel will have already been initialized. This function isn't used anywhere in the tree, so I'm guessing that it is maybe used by some via the debugger. --- libs/wine/debug.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/libs/wine/debug.c b/libs/wine/debug.c index 8b04ef9..8a82955 100644 --- a/libs/wine/debug.c +++ b/libs/wine/debug.c @@ -62,15 +62,19 @@ unsigned char __wine_dbg_get_channel_flags( struct __wine_debug_channel *channel { if (nb_debug_options == -1) debug_init(); - if (nb_debug_options) + /* init if uninitialized */ + if (channel->flags & (1 << __WINE_DBCL_INIT)) { - struct __wine_debug_channel *opt = bsearch( channel->name, debug_options, nb_debug_options, - sizeof(debug_options[0]), cmp_name ); - if (opt) return opt->flags; + struct __wine_debug_channel *opt = NULL; + + if (nb_debug_options) + opt = bsearch( channel->name, debug_options, nb_debug_options, + sizeof(debug_options[0]), cmp_name ); + + channel->flags = opt ? opt->flags : default_flags; } - /* no option for this channel */ - if (channel->flags & (1 << __WINE_DBCL_INIT)) channel->flags = default_flags; - return default_flags; + + return channel->flags; } /* set the flags to use for a given channel; return 0 if the channel is not available to set */ -- 2.4.6