summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorSergey Vojtovich <svoj@mariadb.org>2019-03-20 01:32:10 +0400
committerSergey Vojtovich <svoj@mariadb.org>2019-05-03 16:46:10 +0400
commit53671a1fff8d4aa0978be2fb916f8e053c09424a (patch)
tree15c669763c7c465bc11f0bc4907aa3a0a6e61d4f /sql
parent1b5cf2f7e7995f8ee17da76eb28633f652852d8f (diff)
downloadmariadb-git-53671a1fff8d4aa0978be2fb916f8e053c09424a.tar.gz
Make connect speed great again
Rather than parsing session_track_system_variables when thread starts, do it when first trackable event occurs. Benchmarked on a 2socket/20core/40threads Broadwell system using sysbench connect brencmark @40 threads (with select 1 disabled): 101379.77 -> 143016.68 CPS, whereas 10.2 is currently at 137766.31 CPS. Part of MDEV-14984 - regression in connect performance
Diffstat (limited to 'sql')
-rw-r--r--sql/log.cc2
-rw-r--r--sql/session_tracker.cc27
-rw-r--r--sql/session_tracker.h1
-rw-r--r--sql/sql_class.cc1
4 files changed, 22 insertions, 9 deletions
diff --git a/sql/log.cc b/sql/log.cc
index 92b2061d4bf..ac885746c62 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -7903,6 +7903,7 @@ MYSQL_BIN_LOG::trx_group_commit_leader(group_commit_entry *leader)
*/
for (current= queue; current != NULL; current= current->next)
{
+ set_current_thd(current->thd);
binlog_cache_mngr *cache_mngr= current->cache_mngr;
/*
@@ -7938,6 +7939,7 @@ MYSQL_BIN_LOG::trx_group_commit_leader(group_commit_entry *leader)
cache_mngr->delayed_error= false;
}
}
+ set_current_thd(leader->thd);
bool synced= 0;
if (unlikely(flush_and_sync(&synced)))
diff --git a/sql/session_tracker.cc b/sql/session_tracker.cc
index 8b0e247767c..db82b7dffe9 100644
--- a/sql/session_tracker.cc
+++ b/sql/session_tracker.cc
@@ -379,16 +379,10 @@ void Session_sysvars_tracker::deinit(THD *thd)
bool Session_sysvars_tracker::enable(THD *thd)
{
- LEX_STRING tmp= { thd->variables.session_track_system_variables,
- safe_strlen(thd->variables.session_track_system_variables) };
orig_list.reinit();
- if (orig_list.parse_var_list(thd, tmp, true, thd->charset()) == true)
- {
- orig_list.reinit();
- m_enabled= false;
- return true;
- }
- m_enabled= true;
+ m_parsed= false;
+ m_enabled= thd->variables.session_track_system_variables &&
+ *thd->variables.session_track_system_variables;
return false;
}
@@ -433,6 +427,7 @@ bool Session_sysvars_tracker::update(THD *thd, set_var *var)
my_free(thd->variables.session_track_system_variables);
thd->variables.session_track_system_variables= static_cast<char*>(copy);
+ m_parsed= true;
orig_list.copy(&tool_list, thd);
orig_list.construct_var_list(thd->variables.session_track_system_variables,
var->save_result.string_value.length + 1);
@@ -540,6 +535,20 @@ void Session_sysvars_tracker::mark_as_changed(THD *thd,
{
sysvar_node_st *node;
sys_var *svar= (sys_var *)var;
+
+ if (!m_parsed)
+ {
+ DBUG_ASSERT(thd->variables.session_track_system_variables);
+ LEX_STRING tmp= { thd->variables.session_track_system_variables,
+ strlen(thd->variables.session_track_system_variables) };
+ if (orig_list.parse_var_list(thd, tmp, true, thd->charset()))
+ {
+ orig_list.reinit();
+ return;
+ }
+ m_parsed= true;
+ }
+
/*
Check if the specified system variable is being tracked, if so
mark it as changed and also set the class's m_changed flag.
diff --git a/sql/session_tracker.h b/sql/session_tracker.h
index 55c78a75978..b6694970c38 100644
--- a/sql/session_tracker.h
+++ b/sql/session_tracker.h
@@ -198,6 +198,7 @@ class Session_sysvars_tracker: public State_tracker
various operations.
*/
vars_list orig_list;
+ bool m_parsed;
public:
void init(THD *thd);
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 97233895fd5..da04ddad49c 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -7304,6 +7304,7 @@ void THD::set_last_commit_gtid(rpl_gtid &gtid)
#ifndef EMBEDDED_LIBRARY
if (changed_gtid && session_tracker.sysvars.is_enabled())
{
+ DBUG_ASSERT(current_thd == this);
session_tracker.sysvars.
mark_as_changed(this, (LEX_CSTRING*)Sys_last_gtid_ptr);
}