[MDEV-22720] Improving performance of my_hash_sort_utf8(mb4)/my_strnncollsp*utf8(mb4) Created: 2020-05-26 Updated: 2023-12-05 |
|
| Status: | Stalled |
| Project: | MariaDB Server |
| Component/s: | Server |
| Affects Version/s: | 10.5.3 |
| Fix Version/s: | 10.5 |
| Type: | Bug | Priority: | Major |
| Reporter: | Dmitriy Philimonov | Assignee: | Alexander Barkov |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | performance | ||
| Issue Links: |
|
||||||||||||||||
| Description |
|
According to our performance investigations, these functions are hot when we Since the commit https://github.com/mysql/mysql-server/commit/67ce24796584
We know that for CHAR(XXX) utf8 fields all unused space is filled with spaces. The performance increase achives by skipping not 1 but 8 spaces for every For my_strnncollsp_utf8 function these approach can't be applied as is.
After that every time when we run into two simultaneous spaces while comparing
Using this simple approach we achived significant performance improvement in If we speak about general database performance, we improve single-threaded Suggested fix: |
| Comments |
| Comment by Eugene Kosov (Inactive) [ 2020-05-26 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I suggest to use `memcmp()` instead of `memcpy()` to a variable. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Alexander Barkov [ 2020-06-08 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thanks for the patch. Can you please tell how you measured speed improvement in case of two strings with a CHAR column? By default, the CHAR data type skips trailing spaces on SELECT.
i.e.:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Alexander Barkov [ 2020-06-11 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
dmitriy.philimonov, can you please give feedback? Thanks. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Dmitriy Philimonov [ 2020-06-15 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Good day, Alexander Sorry for so long delay, we're suffering from a high time pressure. I've looked through the code again, here's a short recap: In the first place, we detected this inefficiency in ```select distinct``` statements using sysbench oltp_ro benchmark (utf8 default charset). Sincerely yours, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Alexander Barkov [ 2020-06-16 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
dmitriy.philimonov, thanks for you feedback. I've created a separate issue For the my_strnncollsp_utf8 change, is there a chance to get your patch for unittest/gunit? Thanks for your contribution! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Dmitriy Philimonov [ 2020-06-16 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Dear Alexander, I'm glad that I was allowed to share the benchmark code with you. It uses unittest/gunit mini-benchmark engine from gtest. If somehow you don't have this engine, it's quite simple to write something similar based on std::chrono:
The benchmark emulates CHAR(120) field. The field is filled with English/Russian/Chinese letters (1/2/3 utf8 bytes per character). The test consists of the cases where the field is filled fully/partially + the first non-equal letter is placed in the beginning/middle/end, or the strings are fully equal. I hope this will help. Put the code in unittest/gunit directory, resolve dependencies, estimate the results.
Sincerely yours, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Julien Fritsch [ 2023-12-05 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Automated message: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by JiraAutomate [ 2023-12-05 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Automated message: |