[MCOL-4580] Extent's approximate range keeping for dictionaries Created: 2021-03-04 Updated: 2023-12-21 |
|
| Status: | In Testing |
| Project: | MariaDB ColumnStore |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 23.10 |
| Type: | Task | Priority: | Major |
| Reporter: | Sergey Zefirov | Assignee: | Sergey Zefirov |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | rm_perf | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||
| Epic Link: | ColumnStore Performance Improvements | ||||||||||||||||||||||||||||||||||||
| Sprint: | 2021-4, 2021-5, 2021-6, 2021-7, 2021-8, 2021-9, 2021-10, 2021-11, 2021-12, 2021-13, 2021-14, 2021-15, 2021-16, 2021-17, 2022-22, 2022-23, 2023-4, 2023-5, 2023-6, 2023-7, 2023-8, 2023-10, 2023-11, 2023-12 | ||||||||||||||||||||||||||||||||||||
| Assigned for Review: | |
||||||||||||||||||||||||||||||||||||
| Assigned for Testing: | |
||||||||||||||||||||||||||||||||||||
| Description |
|
Following the ideas from the design document, we may add extent range information for dictionaries. Token columns are, essentially, 8-byte-wide unsigned integers. They can be tracked just like other integer columns in extentmap. But instead of tracking values of tokens we will track values of prefixes of corresponding dictionary strings, with collation applied. I will add more precise plan to comments below. |
| Comments |
| Comment by Sergey Zefirov [ 2021-03-10 ] | |||||||||||||||||||||||||||||||
|
Relevant branch: https://github.com/mariadb-SergeyZefirov/mariadb-columnstore-engine/tree/MCOL-4580-extent-range-keeping-for-dictionaries Let's start with functionality tests! | |||||||||||||||||||||||||||||||
| Comment by Sergey Zefirov [ 2021-03-25 ] | |||||||||||||||||||||||||||||||
|
cpimport does not handle collation(s). | |||||||||||||||||||||||||||||||
| Comment by Sergey Zefirov [ 2021-03-25 ] | |||||||||||||||||||||||||||||||
|
Why would it - we process collations dynamically during query plan execution. This is relatively good, actually. | |||||||||||||||||||||||||||||||
| Comment by Sergey Zefirov [ 2021-03-26 ] | |||||||||||||||||||||||||||||||
|
https://collation-charts.org/mysql60/mysql604.utf8_slovak_ci.html - recommended by bar. Please note that CH (sequence of chars 0x43 0x48) goes between H (0x48) and I (0x49) with code 0x49. | |||||||||||||||||||||||||||||||
| Comment by Sergey Zefirov [ 2021-03-26 ] | |||||||||||||||||||||||||||||||
|
Corner case: part Slovakian, part Russian string in the column with Slovakian collation. The Solvakian part must be sorted (eliminated) accordingly to Slovakian rules and Russian parts should be sorted accordingly to Russian rules. | |||||||||||||||||||||||||||||||
| Comment by Sergey Zefirov [ 2021-03-26 ] | |||||||||||||||||||||||||||||||
|
The rules of Slovakian collation calls for, let say, "safe min/max" computations for strings. The accented O (Ó) if put in range as it is (code 0xd3) will make us to think that "y" (code 0x79) is also included. Which ay not be a case. | |||||||||||||||||||||||||||||||
| Comment by Sergey Zefirov [ 2021-03-26 ] | |||||||||||||||||||||||||||||||
|
Test I have right now depends on the | |||||||||||||||||||||||||||||||
| Comment by Sergey Zefirov [ 2021-03-29 ] | |||||||||||||||||||||||||||||||
|
https://collation-charts.org/mysql60/mysql604.koi8r_general_ci.html A collation table where 0xFF (Ъ) is lexically smaller than 0xF1 (Я). | |||||||||||||||||||||||||||||||
| Comment by Sergey Zefirov [ 2021-03-29 ] | |||||||||||||||||||||||||||||||
|
Interesting bits from bar:
weight_string corresponds to
And
This last function expands a string ("a%") with characters corresponding to first and last (in sorting order sense) strings for a collation. | |||||||||||||||||||||||||||||||
| Comment by Sergey Zefirov [ 2021-03-29 ] | |||||||||||||||||||||||||||||||
|
(debug build of MariaDB) The script:
The result:
It is a result of "like_range" application above. | |||||||||||||||||||||||||||||||
| Comment by Sergey Zefirov [ 2021-04-07 ] | |||||||||||||||||||||||||||||||
|
Have some small success:
The 7061644215716938000 is 0x*62*00000000000110 - I've got almost valid prefix for string 'b'. The junk in lower bytes is a question I will debug shortly. | |||||||||||||||||||||||||||||||
| Comment by Sergey Zefirov [ 2021-04-09 ] | |||||||||||||||||||||||||||||||
|
The "signedness" of column type partially depends on the width of the column. This made me make column range signed. It looks like job execution engine already tries to skip some extents and incorrectly panics. | |||||||||||||||||||||||||||||||
| Comment by Sergey Zefirov [ 2021-04-12 ] | |||||||||||||||||||||||||||||||
|
TupleBPS::makeJobs receive TOKEN extents with type TEXT and size 8. Due to CasualPartitioningType logic, these columns are not CP-elimination eligible. This means they will be scanned anyway. I have to think how to overcome this limitation. | |||||||||||||||||||||||||||||||
| Comment by Sergey Zefirov [ 2021-04-13 ] | |||||||||||||||||||||||||||||||
|
TOKEN columns are marked as TEXT with width=8 in CalpontSystemCatalog nomenclature. The CasualPartitionDataType(ColDataType, int) predicate in LbidList checks if width is < 8 for TEXT columns - in that case they are eligible for elimination. I've changed the comparison to width <= 8. This change made TOKEN extent in my test to be scrutinized with predicates. There is single predicate on that extent (which is correct) but the list of filters in that predicate is empty. That means that extent is marked to scan - filters can only eliminate extents from scanning and there are no filters to eliminate. | |||||||||||||||||||||||||||||||
| Comment by Sergey Zefirov [ 2021-04-19 ] | |||||||||||||||||||||||||||||||
|
The test SQL code:
Now the first run of my test without any attempt of adding filter that will remove TOKEN extent.
And second run of the same test, but when I added a filter to a TOKEN column:
Note that counts for PIO and LIO are changed. Also warnings report shows less blocks touched. We read less blocks. I think we still read dictionary for some reason and plan to investigate on that. | |||||||||||||||||||||||||||||||
| Comment by Sergey Zefirov [ 2021-05-14 ] | |||||||||||||||||||||||||||||||
|
Each dictionary column is split into two parts: TOKEN column which contains references of actual data and actual dictionary data. The dictionary data extent does not contain structured information, it contains information whose structure is defined elsewhere - in the TOKEN column. Before any changes related to this task the situation was as follows: when we tried to eliminate dictionary extents we applied predicates to the dictionary data extents, not to the TOKEN extents. It may turn to be not necessary at all and right now I am looking to prove that. E.g., we can leave only scan operation for TOKEN extents and drop out operation on the dictionary data extents. | |||||||||||||||||||||||||||||||
| Comment by Sergey Zefirov [ 2021-05-18 ] | |||||||||||||||||||||||||||||||
|
Tokens (write engine parlance) in old calpont code are TEXT columns with width exactly 8. So they are treated everywhere as if they are of type CHAR(8). For example, this is the code in lbidlist.cpp, CasualPartitioningPredicate method:
The Casual Partitioning range values and value itself are treated as if they are strings, encoded as integers. This direct conversion is compatible with handlng of ranges in different parts of CS engine (versioning, mainly) only for big endian platforms. The code above is also not quite correct because we would like to keep ranges' values in the collated state anyway. It may be possible that ranges are not correctly kept in the present design - I have to investigate. | |||||||||||||||||||||||||||||||
| Comment by Sergey Zefirov [ 2021-05-19 ] | |||||||||||||||||||||||||||||||
|
I've got BlocksTouched=0 on this test:
SHOW WARNINGS report:
I've got (even before fix of code above) the following:
This means that ranges for TOKEN column are kept in the different state across program components. I'm on investigation of that phenomena. | |||||||||||||||||||||||||||||||
| Comment by Sergey Zefirov [ 2021-05-25 ] | |||||||||||||||||||||||||||||||
|
The source of "Image inconsistency" result was due to WriteEngineServer crash:
The answer to a broadcast message was empty (WE server is down), it was not the same as other answers (I presume they are correct) and as a result of answers divergence we've got "image inconsistency" error. | |||||||||||||||||||||||||||||||
| Comment by Sergey Zefirov [ 2021-05-26 ] | |||||||||||||||||||||||||||||||
|
Complete stack trace:
| |||||||||||||||||||||||||||||||
| Comment by Sergey Zefirov [ 2021-05-26 ] | |||||||||||||||||||||||||||||||
|
The problem above was fixed by updating to the fresh version of MCS and, subsquently, server. I have MTR running right now and some tests pass. The failing ones so far are testing collation functionality. | |||||||||||||||||||||||||||||||
| Comment by Sergey Zefirov [ 2021-05-26 ] | |||||||||||||||||||||||||||||||
|
I was too optimistic about the segfault. Most of tests below were failing with "Lost connection to DDLProc":
| |||||||||||||||||||||||||||||||
| Comment by Sergey Zefirov [ 2021-05-28 ] | |||||||||||||||||||||||||||||||
|
I had segfaults for the test columnstore/basic.ctype_cmp_varchar32_latin1_bin in the native centos build. But it passes under valgrind. A strange situation. | |||||||||||||||||||||||||||||||
| Comment by Sergey Zefirov [ 2021-06-09 ] | |||||||||||||||||||||||||||||||
|
The crash was due to use of non-managed pointer instead of shared_ptr. Right now crash is absent and I am working on the tests (I have exception raised during INSERT operation). | |||||||||||||||||||||||||||||||
| Comment by Sergey Zefirov [ 2021-06-09 ] | |||||||||||||||||||||||||||||||
|
Fixed the exception. Now I wait for MTR tests to finish to see what I broke. Thus far my changes broke many tests dealing with collation. | |||||||||||||||||||||||||||||||
| Comment by Sergey Zefirov [ 2021-06-09 ] | |||||||||||||||||||||||||||||||
|
MTR reports "Completed: Failed 183/435 tests, 57.93% were successful." 90 of failing tests are There were wide decimal failures and more. Of course, there are failures in tests dealing with collations. | |||||||||||||||||||||||||||||||
| Comment by Sergey Zefirov [ 2021-06-10 ] | |||||||||||||||||||||||||||||||
|
One of affected tests is mcs24 "INSERT from another table". Which throws an exception in one of queries and does not clean things up. This is one reason why | |||||||||||||||||||||||||||||||
| Comment by Sergey Zefirov [ 2021-06-11 ] | |||||||||||||||||||||||||||||||
|
Here are latest results:
An improvement upon what was before. | |||||||||||||||||||||||||||||||
| Comment by Sergey Zefirov [ 2021-06-15 ] | |||||||||||||||||||||||||||||||
|
After added cleanup of my mcol4580 tests, I've reduced number of failing tests to 8:
| |||||||||||||||||||||||||||||||
| Comment by Sergey Zefirov [ 2021-06-15 ] | |||||||||||||||||||||||||||||||
|
Fixed handling of LIKE/NLIKE, got 5 tests failing:
| |||||||||||||||||||||||||||||||
| Comment by Sergey Zefirov [ 2021-09-30 ] | |||||||||||||||||||||||||||||||
|
The failure of queries in the comment just above was a fluke - it appears that right now regression tests may fail differently in a different days of year. Appropriate bug reported here. When I've run these tests for 10.6/develop and for my patch in tight succession, I've got only problems with IS NULL. The operation "column IS NULL" is translated to an equality test with the specific value, e.g., "column=COLUMN_TYPE_NULL_VALUE". Logs indicate that type used for comparison in extent elimination code is the code used for short character strings, because token columns in ColumnStore are marked as CHARACTER columns with width 8 (exactly short char strings). It is not signedness as I suspected, but type error nonetheless. | |||||||||||||||||||||||||||||||
| Comment by Roman [ 2022-03-03 ] | |||||||||||||||||||||||||||||||
|
Implemented but the issue will be waiting for a prerequisite. | |||||||||||||||||||||||||||||||
| Comment by Roman [ 2022-08-16 ] | |||||||||||||||||||||||||||||||
|
Can not deliver in time for 22.08.01 so moving this important perf optimization to a later release. | |||||||||||||||||||||||||||||||
| Comment by Kirill Perov [ 2023-12-02 ] | |||||||||||||||||||||||||||||||
|
sergey.zefirov is veeeery long winded... It's difficult to find reproduction script, can you point it? |