summaryrefslogtreecommitdiff
path: root/sql/sql_profile.h
diff options
context:
space:
mode:
authorSergey Vojtovich <svoj@mariadb.org>2015-04-15 18:12:23 +0400
committerSergey Vojtovich <svoj@mariadb.org>2015-05-13 10:43:13 +0400
commit5cfb6b479efd05fafc77caf94d60240b879d5073 (patch)
treef35853d2a164d3c437e052d49ef2cf23b357cfa6 /sql/sql_profile.h
parent55d5af733d97808a1479b185c029ac0121c0f158 (diff)
downloadmariadb-git-5cfb6b479efd05fafc77caf94d60240b879d5073.tar.gz
MDEV-7999 - PROFILING routines take 0.2% when profiling disabled
PROFILING::start_new_query() optimizations: - no need to check "current": added assertion instead - "enabled" now means "is enabled currently" instead of "was enabled at query start". Old meaning was useless, new meaning echoes OPTION_PROFILING so that start_new_query() can be defined in sql_profile.h. - remnants of start_new_query() moved to sql_profile.h so it can be inlined PROFILING::start_new_query() overhead dropped 0.08% -> out of radar. PROFILING::set_query_source() optimizations: - no need to check "enabled": !enabled && current is impossible - remnants of set_query_source() moved to sql_profile.h so it can be inlined PROFILING::set_query_source() overhead dropped 0.02% -> out of radar. PROFILING::finish_current_query() optimizations: - moved "current" check out to sql_profile.h so it can be inlined PROFILING::finish_current_query() overhead dropped 0.10% -> out of radar.
Diffstat (limited to 'sql/sql_profile.h')
-rw-r--r--sql/sql_profile.h44
1 files changed, 37 insertions, 7 deletions
diff --git a/sql/sql_profile.h b/sql/sql_profile.h
index 52eaba49181..1d770ca1147 100644
--- a/sql/sql_profile.h
+++ b/sql/sql_profile.h
@@ -268,32 +268,62 @@ private:
public:
PROFILING();
~PROFILING();
- void set_query_source(char *query_source_arg, uint query_length_arg);
- void start_new_query(const char *initial_state= "starting");
+ /**
+ At a point in execution where we know the query source, save the text
+ of it in the query profile.
+
+ This must be called exactly once per descrete statement.
+ */
+ void set_query_source(char *query_source_arg, uint query_length_arg)
+ {
+ if (unlikely(current))
+ current->set_query_source(query_source_arg, query_length_arg);
+ }
+
+ /**
+ Prepare to start processing a new query. It is an error to do this
+ if there's a query already in process; nesting is not supported.
+
+ @param initial_state (optional) name of period before first state change
+ */
+ void start_new_query(const char *initial_state= "starting")
+ {
+ DBUG_ASSERT(!current);
+ if (unlikely(enabled))
+ current= new QUERY_PROFILE(this, initial_state);
+ }
void discard_current_query();
- void finish_current_query();
+ void finish_current_query()
+ {
+ if (unlikely(current))
+ finish_current_query_impl();
+ }
+
+ void finish_current_query_impl();
void status_change(const char *status_arg,
const char *function_arg,
const char *file_arg, unsigned int line_arg)
{
if (unlikely(current))
- {
- DBUG_ASSERT(enabled);
current->new_status(status_arg, function_arg, file_arg, line_arg);
- }
}
- inline void set_thd(THD *thd_arg) { thd= thd_arg; };
+ inline void set_thd(THD *thd_arg)
+ {
+ thd= thd_arg;
+ reset();
+ }
/* SHOW PROFILES */
bool show_profiles();
/* ... from INFORMATION_SCHEMA.PROFILING ... */
int fill_statistics_info(THD *thd, TABLE_LIST *tables, Item *cond);
+ void reset();
};
# endif /* ENABLED_PROFILING */