Type:
Task
Priority:
Major
Resolution:
Fixed
Binary collations to be improved
The following binary multi-byte collations (together with their _nopad_bin counterparts):
big5_bin
cp932_bin
eucjpms_bin
euckr_bin
gb2312_bin
gbk_bin
sjis_bin
ujis_bin
utf8mb3_bin
utf8mb4_bin
can improve their performance if in this code in strcoll.ic:
static int
MY_FUNCTION_NAME(strnncollsp)(CHARSET_INFO *cs __attribute__((unused)),
const uchar *a, size_t a_length,
const uchar *b, size_t b_length)
{
const uchar *a_end= a + a_length;
const uchar *b_end= b + b_length;
for ( ; ; )
{
int a_weight, b_weight, res;
uint a_wlen= MY_FUNCTION_NAME(scan_weight)(&a_weight, a, a_end);
...
we catch pure ASCII and try to handle 4 or even 8 bytes in one iteration by loading string data into big-endian uint32 or uint64 numbers, then comparing these two numbers.
Case insensitive collations to be improved
Additionally, the following case insensitive multibyte collations (and their _nopad_ci counteparts):
utf8mb3_general_ci
utf8mb3_general_mysql500_ci
utf8mb4_general_ci
cp932_japanese_ci
eucjpms_japanese_ci
euckr_korean_ci
sjis_japanese_ci
ujis_japanese_ci
can use the same idea because for ASCII they perform only a trivial mapping from lower case Latin letters [a-z] to their upper case counterparts [A-Z] , and after this mapping done the comparison is performed in binary style. These collations can do the following on every iteration step:
Test the leading 4 or 8 bytes in the two strings for pure ASCII data and go to the old code on failure (to handle multi-byte characters)
Load the two strings into two uint32 or uint64 numbers
Perform bulk conversion of all bytes in the two numbers from [61..7A] to [41..5A] (i.e. from [a-z] to [A-Z] )
Compare the numbers and return if they are different
Increment pointers to 4 or 8 and continue the loop
Note, the exact way of bulk conversion of numbers to upper case is to be found out by the developer.
Requirements
The performance of the low level comparison functions can be measured by the BENCHMARK() SQL functions, e.g.:
SET NAMES utf8mb3 COLLATE utf8mb3_general_ci;
SELECT BENCHMARK(10000000, 'aaaaaaaaaaaaaaaa' = 'aaaaaaaaaaaaaaaa' );
The expected performance improvement on the pure ASCII data (for strings with octet length >= 4) is between 2 and 3 times (depending on the exact length and collation).
Note, the changes must be done in a way not to bring any serious (more than 10%) slow down for:
strings with multi-byte characters
short strings 1..3 bytes long
Collations that won't be changed in this task
8bit case insensitive collations
MariaDB has a number of 8bit case insensitive collations with trivial toupper mapping on the ASCII range. So they can get optimized in the same way. But we'll improve these collations under terms of a separate task because they don't use the mentioned code and have their own implementations.
Three Chinese case insensitive collations
Also, under terms of this task we won't change the following multi-byte case insensitive collations (and their _nopad_ci counterparts):
big5_chinese_ci
gb2312_chinese_ci
gbk_chinese_ci
because all these three collations additionally change the order of some ASCII punctuation characters:
Weight
Character name
Character
0x5B
U+005D RIGHT SQUARE BRACKET
]
0x5C
U+005B LEFT SQUARE BRACKET
[
0x5D
U+005C REVERSE SOLIDUS
|
So on the bulk conversion step they need more efforts and the proposed optimization may not be efficient. These collations will be improved later under terms of a separate task.
Case insensitive _general_ci collations for ucs2, utf16, utf32
These character sets have separate implementations and don't use the mentioned code. They'll be improved under terms of a separate task.
{"report":{"fcp":1185.5999999046326,"ttfb":365.40000009536743,"pageVisibility":"visible","entityId":102595,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"e3f86ba0-6ec4-462c-8261-5a806d133a9a","navigationType":0,"readyForUser":1295.0999999046326,"redirectCount":0,"resourceLoadedEnd":914.3000001907349,"resourceLoadedStart":379.80000019073486,"resourceTiming":[{"duration":71.09999990463257,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":379.80000019073486,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":379.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":450.90000009536743,"responseStart":0,"secureConnectionStart":0},{"duration":71.7000002861023,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/download/contextbatch/css/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true&whisper-enabled=true","startTime":380.09999990463257,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":380.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":451.80000019073486,"responseStart":0,"secureConnectionStart":0},{"duration":407.7999997138977,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":380.30000019073486,"connectEnd":380.30000019073486,"connectStart":380.30000019073486,"domainLookupEnd":380.30000019073486,"domainLookupStart":380.30000019073486,"fetchStart":380.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":459.7000002861023,"responseEnd":788.0999999046326,"responseStart":492.5,"secureConnectionStart":380.30000019073486},{"duration":521.0999999046326,"initiatorType":"script","name":"https://jira.mariadb.org/s/2d8175ec2fa4c816e8023260bd8c1786-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/download/contextbatch/js/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true&whisper-enabled=true","startTime":381,"connectEnd":381,"connectStart":381,"domainLookupEnd":381,"domainLookupStart":381,"fetchStart":381,"redirectEnd":0,"redirectStart":0,"requestStart":460,"responseEnd":902.0999999046326,"responseStart":499.80000019073486,"secureConnectionStart":381},{"duration":125.19999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/s/a9324d6758d385eb45c462685ad88f1d-CDN/lu2cib/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":381.2000002861023,"connectEnd":381.2000002861023,"connectStart":381.2000002861023,"domainLookupEnd":381.2000002861023,"domainLookupStart":381.2000002861023,"fetchStart":381.2000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":460.09999990463257,"responseEnd":506.40000009536743,"responseStart":503.2000002861023,"secureConnectionStart":381.2000002861023},{"duration":121.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":381.40000009536743,"connectEnd":381.40000009536743,"connectStart":381.40000009536743,"domainLookupEnd":381.40000009536743,"domainLookupStart":381.40000009536743,"fetchStart":381.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":460,"responseEnd":502.90000009536743,"responseStart":501.80000019073486,"secureConnectionStart":381.40000009536743},{"duration":126.10000038146973,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":381.59999990463257,"connectEnd":381.59999990463257,"connectStart":381.59999990463257,"domainLookupEnd":381.59999990463257,"domainLookupStart":381.59999990463257,"fetchStart":381.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":460.30000019073486,"responseEnd":507.7000002861023,"responseStart":504.59999990463257,"secureConnectionStart":381.59999990463257},{"duration":71.30000019073486,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2cib/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":381.90000009536743,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":381.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":453.2000002861023,"responseStart":0,"secureConnectionStart":0},{"duration":124.59999990463257,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":382,"connectEnd":382,"connectStart":382,"domainLookupEnd":382,"domainLookupStart":382,"fetchStart":382,"redirectEnd":0,"redirectStart":0,"requestStart":460.30000019073486,"responseEnd":506.59999990463257,"responseStart":503.80000019073486,"secureConnectionStart":382},{"duration":71.19999980926514,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2cib/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/css/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.css?jira.create.linked.issue=true","startTime":382.2000002861023,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":382.2000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":453.40000009536743,"responseStart":0,"secureConnectionStart":0},{"duration":125.69999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/s/5d5e8fe91fbc506585e83ea3b62ccc4b-CDN/lu2cib/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/js/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.js?jira.create.linked.issue=true&locale=en","startTime":382.40000009536743,"connectEnd":382.40000009536743,"connectStart":382.40000009536743,"domainLookupEnd":382.40000009536743,"domainLookupStart":382.40000009536743,"fetchStart":382.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":461.59999990463257,"responseEnd":508.09999990463257,"responseStart":505.30000019073486,"secureConnectionStart":382.40000009536743},{"duration":519.9000000953674,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":393,"connectEnd":393,"connectStart":393,"domainLookupEnd":393,"domainLookupStart":393,"fetchStart":393,"redirectEnd":0,"redirectStart":0,"requestStart":796.7000002861023,"responseEnd":912.9000000953674,"responseStart":904.8000001907349,"secureConnectionStart":393},{"duration":518.8000001907349,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":395.5,"connectEnd":395.5,"connectStart":395.5,"domainLookupEnd":395.5,"domainLookupStart":395.5,"fetchStart":395.5,"redirectEnd":0,"redirectStart":0,"requestStart":880.2000002861023,"responseEnd":914.3000001907349,"responseStart":909.7000002861023,"secureConnectionStart":395.5},{"duration":174.10000038146973,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":932.5999999046326,"connectEnd":932.5999999046326,"connectStart":932.5999999046326,"domainLookupEnd":932.5999999046326,"domainLookupStart":932.5999999046326,"fetchStart":932.5999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":1066.7000002861023,"responseEnd":1106.7000002861023,"responseStart":1105.9000000953674,"secureConnectionStart":932.5999999046326}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":151,"responseStart":365,"responseEnd":395,"domLoading":371,"domInteractive":1404,"domContentLoadedEventStart":1404,"domContentLoadedEventEnd":1467,"domComplete":2567,"loadEventStart":2567,"loadEventEnd":2567,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1379.4000000953674},{"name":"bigPipe.sidebar-id.end","time":1380.2000002861023},{"name":"bigPipe.activity-panel-pipe-id.start","time":1380.4000000953674},{"name":"bigPipe.activity-panel-pipe-id.end","time":1382},{"name":"activityTabFullyLoaded","time":1485.4000000953674}],"measures":[],"correlationId":"df0c20c65df3f2","effectiveType":"4g","downlink":9.3,"rtt":0,"serverDuration":135,"dbReadsTimeInMs":28,"dbConnsTimeInMs":40,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}