[MDEV-23478] Improve Protocol performance for numeric data - version 2 Created: 2020-08-14 Updated: 2020-10-06 Resolved: 2020-08-14 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Binary Protocol, Character Sets |
| Fix Version/s: | 10.5.7 |
| Type: | Task | Priority: | Major |
| Reporter: | Alexander Barkov | Assignee: | Alexander Barkov |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
||||||||
| Issue Links: |
|
||||||||
| Description |
|
Monty proposed an alternative solution, instead of the repertoire-based improvement implemented in The idea is to make Field send itself to Protocol_text using data type specific Protocol methods (like in Protocol_binary) rather than field->val_str() followed by protocol_text->store_str(). The data type specific methods for numeric and temporal data types in Protocol_text can use a new method Protocol_text::store_numeric_string_aux() instead of the generic store_string_aux(). Additional performance improvement (comparing to the previous implementation with repertoire) should be achieved because the test condition in store_numeric_string_aux() detecting if a character set conversion is needed is much simpler than the one in store_string_aux():
So for numeric and temporal data instead of calling this generic string method in store_string_aux():
the condition in store_numeric_string_aux() will be as simple as this:
And this generic string call:
for numeric and temporal data will change to:
Notice, we remove a lot of parameters and one virtual call. Bar proposed additional changes: As after introducing data type specific methods in Protocol_text, Field will send itself in a very similar way to all protocol types
This approach makes the code very symmetric:
Such unification will allow to reuse the code between protocols and Field vs Item, which means less potential bugs. BenchmarkingAfter implementing, the new approach demonstrated improvement comparing to the repertoire based implementation. Tools used:
The result of "time ./num" for various commits:
The new approach (#4) stably demonstrates better performance over the repertoire based one (#2). |