From: Date: August 1 2006 6:12pm Subject: Re: SHOW PROFILE and PATCH/5.1: Change thd->proc_info accesses to a macro List-Archive: http://lists.mysql.com/internals/33771 Message-Id: <44CF7D71.3030605@provenscaling.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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