From 2c39f69d34e64a5cf94720e82e78c0ee91bd4649 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 24 Apr 2020 15:25:39 +0300 Subject: MDEV-22203: WSREP_ON is unnecessarily expensive WITH_WSREP=OFF If the server is compiled WITH_WSREP=OFF, we should avoid evaluating conditions on a global variable that is constant. WSREP_ON_: Renamed from WSREP_ON. Defined only WITH_WSREP=ON. WSREP_ON: Defined as unlikely(WSREP_ON_). wsrep_on(): Defined as WSREP_ON && wsrep_service->wsrep_on_func(). The reason why we have wsrep_on() at all is that the macro WSREP(thd) depends on the definition of THD, and that is intentionally an opaque data type for InnoDB. So, we cannot avoid invoking wsrep_on(), but we can evaluate the less expensive condition WSREP_ON before calling the function. --- sql/wsrep_mysqld.cc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'sql/wsrep_mysqld.cc') diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index c1a289cf685..14be333c107 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -770,10 +770,7 @@ int wsrep_init() global_system_variables.wsrep_on= 1; - if (wsrep_provider && strcmp(wsrep_provider, WSREP_NONE)) - WSREP_ON= true; - else - WSREP_ON= false; + WSREP_ON_= wsrep_provider && strcmp(wsrep_provider, WSREP_NONE); if (wsrep_gtid_mode && opt_bin_log && !opt_log_slave_updates) { -- cgit v1.2.1