Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
10.1.17, 10.2.2, 10.3.0, 10.4.0, 10.5.0
Description
The macro WSREP_ON used to be defined simply as an alias the global Boolean variable global_system_variables.wsrep_on. A more complex variant that invokes strcmp was introduced, in MDEV-16799 renamed to WSREP_ON_NEW, and related to MDEV-16405 (Galera 4) in 10.4.2 the more efficient macro WSREP_ON was replaced altogether.
The following looks grossly inefficient:
#define WSREP_ON \
|
((global_system_variables.wsrep_on) && \
|
wsrep_provider && \
|
strcmp(wsrep_provider, WSREP_NONE)) |
|
/* use xxxxxx_NNULL macros when thd pointer is guaranteed to be non-null to
|
* avoid compiler warnings (GCC 6 and later) */
|
#define WSREP_NNULL(thd) \
|
(thd->variables.wsrep_on && WSREP_ON)
|
|
#define WSREP(thd) \
|
(thd && WSREP_NNULL(thd))
|
Why does the Boolean predicate WSREP_ON have to be so complex? We should be able to compute one global Boolean variable, something like this:
extern my_bool WSREP_ON; |
#define WSREP_NNULL(thd) (WSREP_ON && thd->variables.wsrep_on)
|
#define WSREP(thd) (thd && WSREP_NNULL(thd)) |
The Boolean variable WSREP_ON would be updated by the update callback functions that would be attached to global_system_variables.wsrep_on and wsrep_provider.
There are rather many checks for WSREP_ON, so this could affect performance, especially starting with MariaDB Server 10.4. I feel that this is important, because the code is being invoked even when Galera is not being used.
MDEV-7962 was filed for performance regressions due to a similar check that is implemented in a non-inlined function wsrep_on(). Could we replace that one with an efficient implementation of the macro WSREP_ON?
Attachments
Issue Links
- relates to
-
MDEV-7962 wsrep_on() takes 0.14% in OLTP RO
- Closed
-
MDEV-16405 Merge Galera 4 changes from mariaDB_wsrep to 10.4
- Closed
-
MDEV-16799 Test wsrep.variables crash at sql_class.cc:639 thd_get_ha_data
- Closed