• Anurag Shekhar's avatar
    Bug #44723 Larger read_buffer_size values can cause performance · 11dd1d6d
    Anurag Shekhar authored
             decrease for INSERTs
    
    
    Bulk inserts (multiple row, CREATE ... SELECT, INSERT ... SELECT) into
    MyISAM tables were performed inefficiently. This was mainly affecting
    use cases where read_buffer_size was considerably large (>256K) and low
    number of rows was inserted (e.g. 30-100).
    
    The problem was that during I/O cache initialization (this happens
    before each bulk insert) allocated I/O buffer was unnecessarily
    initialized to '\0'.
    
    This was happening because of mess in flag values. MyISAM informs I/O
    cache to wait for free space (if out of disk space) by passing
    MY_WAIT_IF_FULL flag. Since MY_WAIT_IF_FULL and MY_ZEROFILL have the
    same values, memory allocator was initializing memory to '\0'.
    
    The performance gain provided with this patch may only be visible with
    non-debug binaries, since safemalloc always initializes allocated memory
    to 0xA5A5...
    
    mysys/mf_iocache.c:
      Remove MY_WAIT_IF_FULL from myflags before calling my_malloc
      to prevent conflict with MY_ZEROFILL.
    11dd1d6d
mf_iocache.c 57.7 KB