Commit 53671a1f authored by Sergey Vojtovich's avatar Sergey Vojtovich

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
parent 1b5cf2f7
......@@ -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)))
......
......@@ -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.
......
......@@ -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);
......
......@@ -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);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment