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_var.cc | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'sql/wsrep_var.cc') diff --git a/sql/wsrep_var.cc b/sql/wsrep_var.cc index a484f8bf113..64362d1c9e2 100644 --- a/sql/wsrep_var.cc +++ b/sql/wsrep_var.cc @@ -88,13 +88,10 @@ static bool refresh_provider_options() } } -static void wsrep_set_wsrep_on(void) +static void wsrep_set_wsrep_on() { - if (global_system_variables.wsrep_on && wsrep_provider && - strcmp(wsrep_provider, WSREP_NONE)) - WSREP_ON= true; - else - WSREP_ON= false; + WSREP_ON_= global_system_variables.wsrep_on && wsrep_provider && + strcmp(wsrep_provider, WSREP_NONE); } /* This is intentionally declared as a weak global symbol, so that -- cgit v1.2.1