List:Internals« Previous MessageNext Message »
From:Jeremy Cole Date:August 1 2006 4:12pm
Subject:Re: SHOW PROFILE and PATCH/5.1: Change thd->proc_info accesses to
a macro
View as plain text  
Hi Jim,

>> 0. Change thd->proc_info access to a macro
> 
> why not add a method to the THD class?

I wouldn't really be opposed to that, but it seems much harder to make 
"zero penalty" when it's disabled.  This is the macro I use in my 
current profiling code:

#if 1
#define THD_PROC_INFO(thd, msg) if(unlikely((thd)->profiling.enabled)) { 
(thd)->profiling.status((msg), __FUNCTION__, __FILE__, __LINE__); } else 
{ (thd)->proc_info= (msg); }
#else
#define THD_PROC_INFO(thd, msg) (thd)->proc_info= (msg);
#endif

(Of course the "1" should change to something smarter...)

If it's disabled at compile time, there is absolutely no penalty, the 
macro pre-compiles into the exact same code that used to be in place. 
If it is enabled at compile time, the branch prediction should be set up 
to have the larger penalty when it is turned on rather than off.

Regards,

Jeremy

-- 
high performance mysql consulting
www.provenscaling.com
Thread
SHOW PROFILE and PATCH/5.1: Change thd->proc_info accesses to a macroJeremy Cole31 Jul
  • Re: SHOW PROFILE and PATCH/5.1: Change thd->proc_info accesses to a macroJim Winstead31 Jul
    • Re: SHOW PROFILE and PATCH/5.1: Change thd->proc_info accesses toa macroJeremy Cole1 Aug
  • Re: SHOW PROFILE and PATCH/5.1: Change thd->proc_info accesses toa macroLenz Grimmer31 Aug
    • Re: SHOW PROFILE and PATCH/5.1: Change thd->proc_info accesses to a macroElliot Murphy31 Aug
      • Re: SHOW PROFILE and PATCH/5.1: Change thd->proc_info accesses toa macroMarc Alff1 Sep
        • Re: SHOW PROFILE and PATCH/5.1: Change thd->proc_info accesses toa macroJeremy Cole1 Sep
    • Re: SHOW PROFILE and PATCH/5.1: Change thd->proc_info accesses toa macroMarc Alff5 Sep
      • Re: SHOW PROFILE and PATCH/5.1: Change thd->proc_info accesses toa macroJeremy Cole5 Sep