[MDEV-22203] WSREP_ON is unnecessarily expensive to evaluate Created: 2020-04-09 Updated: 2020-04-27 Resolved: 2020-04-24 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Galera |
| Affects Version/s: | 10.1.17, 10.2.2, 10.3.0, 10.4.0, 10.5.0 |
| Fix Version/s: | 10.1.45, 10.2.32, 10.3.23, 10.4.13, 10.5.3 |
| Type: | Bug | Priority: | Major |
| Reporter: | Marko Mäkelä | Assignee: | Jan Lindström (Inactive) |
| Resolution: | Fixed | Votes: | 1 |
| Labels: | performance | ||
| Attachments: |
|
||||||||||||||||
| Issue Links: |
|
||||||||||||||||
| 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 The following looks grossly inefficient:
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:
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.
|
| Comments |
| Comment by Axel Schwenke [ 2020-04-21 ] |
|
I ran some standard sysbench workloads on MariaDB 10.4.12 with WSREP compiled in or not compiled in. As expected, disabling WSREP gives a small performance improvement. Also as expected, this improvement is bigger for write-intensive workload. The improvement is however small, in the order of 2%. |
| Comment by Michael Widenius [ 2020-04-22 ] |
|
Axel, did you test with and without binary logging? The proper and only acceptable fix is to change the code to use a Boolean variable for the check. |
| Comment by Axel Schwenke [ 2020-04-22 ] |
|
monty : this test was without binlog. But I can easily run it again with binlog enabled. |
| Comment by Axel Schwenke [ 2020-04-22 ] |
|
I updated the attachments with results from the benchmark; rerun with binlogging enabled. The general numbers dropped with binlogging enabled (as expected). It also looks like the difference between WITH_WSREP=1 and WITH_WSREP=0 gets smaller when binlogging is enabled. This is also expected. Binlogging adds latency to query processing (at least while waiting for the disk), so any constant overhead (we expect such overhead for WSREP=On checks) will look smaller in relation to the overall processing time. |
| Comment by Marko Mäkelä [ 2020-04-26 ] |
|
Before 10.4, WSREP only reads a global variable, and WSREP_ON_NEW was always unused. |