Uploaded image for project: 'Percona Server for MySQL'
  1. Percona Server for MySQL
  2. PS-1320

LP #1132350: Suboptimal code in my_strnxfrm_simple()

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Done
    • Priority: High
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:

      Description

      **Reported in Launchpad by Alexey Kopytov last update 22-05-2013 11:11:35

      This ancient code in my_strnxfrm_simple() is suboptimal:

      if (dest != src)

      { const uchar *end; for ( end=src+len; src < end ; ) *dest++= map[*src++]; }

      else

      { const uchar *end; for ( end=dest+len; dest < end ; dest++) *dest= (char) map[(uchar) *dest]; }

      I can't see any difference between these branches. It's probably
      remnants from _bin collations, where we don't have to do table
      translation and thus the "dest == src" case is degenerate, e.g.:

      static size_t my_strnxfrm_bin(CHARSET_INFO *cs _attribute_((unused)),
      uchar *dest, size_t dstlen,
      const uchar *src, size_t srclen)
      {
      if (dest != src)
      memcpy(dest, src, min(dstlen,srclen));
      if (dstlen > srclen)
      bfill(dest + srclen, dstlen - srclen, 0);
      return dstlen;
      }

      But the "if()" statement in my_strnxfrm_simple() is redundant. It is
      executed for each row processed by filesort and shows high branch
      misprediction numbers in sysbench RO runs.

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            lpjirasync lpjirasync (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Smart Checklist