Skip to content

Commit 53671a1

Browse files
committed
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
1 parent 1b5cf2f commit 53671a1

File tree

4 files changed

+22
-9
lines changed

4 files changed

+22
-9
lines changed

sql/log.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7903,6 +7903,7 @@ MYSQL_BIN_LOG::trx_group_commit_leader(group_commit_entry *leader)
79037903
*/
79047904
for (current= queue; current != NULL; current= current->next)
79057905
{
7906+
set_current_thd(current->thd);
79067907
binlog_cache_mngr *cache_mngr= current->cache_mngr;
79077908

79087909
/*
@@ -7938,6 +7939,7 @@ MYSQL_BIN_LOG::trx_group_commit_leader(group_commit_entry *leader)
79387939
cache_mngr->delayed_error= false;
79397940
}
79407941
}
7942+
set_current_thd(leader->thd);
79417943

79427944
bool synced= 0;
79437945
if (unlikely(flush_and_sync(&synced)))

sql/session_tracker.cc

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -379,16 +379,10 @@ void Session_sysvars_tracker::deinit(THD *thd)
379379

380380
bool Session_sysvars_tracker::enable(THD *thd)
381381
{
382-
LEX_STRING tmp= { thd->variables.session_track_system_variables,
383-
safe_strlen(thd->variables.session_track_system_variables) };
384382
orig_list.reinit();
385-
if (orig_list.parse_var_list(thd, tmp, true, thd->charset()) == true)
386-
{
387-
orig_list.reinit();
388-
m_enabled= false;
389-
return true;
390-
}
391-
m_enabled= true;
383+
m_parsed= false;
384+
m_enabled= thd->variables.session_track_system_variables &&
385+
*thd->variables.session_track_system_variables;
392386
return false;
393387
}
394388

@@ -433,6 +427,7 @@ bool Session_sysvars_tracker::update(THD *thd, set_var *var)
433427
my_free(thd->variables.session_track_system_variables);
434428
thd->variables.session_track_system_variables= static_cast<char*>(copy);
435429

430+
m_parsed= true;
436431
orig_list.copy(&tool_list, thd);
437432
orig_list.construct_var_list(thd->variables.session_track_system_variables,
438433
var->save_result.string_value.length + 1);
@@ -540,6 +535,20 @@ void Session_sysvars_tracker::mark_as_changed(THD *thd,
540535
{
541536
sysvar_node_st *node;
542537
sys_var *svar= (sys_var *)var;
538+
539+
if (!m_parsed)
540+
{
541+
DBUG_ASSERT(thd->variables.session_track_system_variables);
542+
LEX_STRING tmp= { thd->variables.session_track_system_variables,
543+
strlen(thd->variables.session_track_system_variables) };
544+
if (orig_list.parse_var_list(thd, tmp, true, thd->charset()))
545+
{
546+
orig_list.reinit();
547+
return;
548+
}
549+
m_parsed= true;
550+
}
551+
543552
/*
544553
Check if the specified system variable is being tracked, if so
545554
mark it as changed and also set the class's m_changed flag.

sql/session_tracker.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ class Session_sysvars_tracker: public State_tracker
198198
various operations.
199199
*/
200200
vars_list orig_list;
201+
bool m_parsed;
201202

202203
public:
203204
void init(THD *thd);

sql/sql_class.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7304,6 +7304,7 @@ void THD::set_last_commit_gtid(rpl_gtid &gtid)
73047304
#ifndef EMBEDDED_LIBRARY
73057305
if (changed_gtid && session_tracker.sysvars.is_enabled())
73067306
{
7307+
DBUG_ASSERT(current_thd == this);
73077308
session_tracker.sysvars.
73087309
mark_as_changed(this, (LEX_CSTRING*)Sys_last_gtid_ptr);
73097310
}

0 commit comments

Comments
 (0)