• Michael Widenius's avatar
    Make SQLString reallocation addaptive · 99e0d496
    Michael Widenius authored
    Avoid doing reallocs
    Prealloc some strings / provide extension allocation size to some strings
    This gave a 25 % speedup in some mysql-test-run tests.
    
    
    
    mysys/safemalloc.c:
      More DBUG_PRINT
    sql/net_serv.cc:
      Make all mallocs() look the similar. (just-for-safety fix)
    sql/protocol.cc:
      Ensure that communication packet buffer is allocated.
      (It's freed by stored precedures and some DLL statements)
    sql/sp.cc:
      Fixed valgrind warning
    sql/sql_select.cc:
      Set extent allocation for buffer that has a lot of append() calls.
    sql/sql_show.cc:
      Fixed wrong usage of string buffer. Old code worked in test suite 'just-by-chance'
    sql/sql_string.cc:
      Call realloc_with_extra_if_needed() in append() functions.
    sql/sql_string.h:
      Added 'extra_alloc' member, to specify chunck size for realloc().
      extra_alloc is addaptive to catch cases where preallocation of buffers is not done properly.
      Simplified free() to allow compiler to optimize things better (and to keep things consistent).
      Fixed shrink() to take into account the extra memory added to the Alloced_length in realloc(). This saves us a realloc() per query.
    sql/sql_test.cc:
      Set extent allocation for buffer that has a lot of append() calls.
    sql/table.cc:
      Set extent allocation for buffer that has a lot of append() calls.
    99e0d496
sql_string.h 12.7 KB