• Alexander Barkov's avatar
    MDEV-23162 Improve Protocol performance for numeric data · c55f24cd
    Alexander Barkov authored
    An alternative implementation (replacing the one based on repertoire).
    
    This implementation makes Field send itself to Protocol_text using
    data type specific Protocol methods rather than field->val_str()
    followed by protocol_text->store_str().
    
    As now Field sends itself in the same way to all protocol types
    (e.g. Protocol_binary, Protocol_text, Protocol_local),
    the method Field::send_binary() was renamed just to Field::send().
    
    Note, this change introduces symmetry between Field and Item,
    because Items also send themself using a single method Item::send(),
    which is used for *all* protocol types.
    
    Performance improvement is achieved by the fact that Protocol_text
    implements these data type specific methods using store_numeric_string_aux()
    rather than store_string_aux(). The conversion now happens only when
    character_set_results is not ASCII compatible character sets
    (e.g. UCS2, UTF16, UTF32).
    
    In the old code (before any MDEV-23162 work, e.g. as of 10.5.4),
    Protocol_text::store(Field*) used val_str() for all data types.
    So the execution went through the character set conversion routines
    even for numeric and temporal data types.
    
    Benchmarking summary (see  details in MDEV-23478):
    
    The new approach stably demonstrates additional improvement comparing
    to the previous implementation (the smaller time - the better):
    
    Original   - the commit before MDEV-23162
                 be98036f
    
            1m9.336s
            1m9.290s
            1m9.300s
    
    MDEV-23162 - the repertoire optimization
    
            1m6.101s
            1m5.988s
            1m6.264s
    
    MDEV-23478 - this commit
    
            1m2.150s
            1m2.079s
            1m2.099s
    c55f24cd
field.cc 325 KB