Percona Server with XtraDB

Suboptimal code in my_strnxfrm_simple()

Reported by Alexey Kopytov on 2013-02-24
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MySQL Server
Unknown
Unknown
Percona Server
Status tracked in 5.6
5.1
Undecided
Unassigned
5.5
Medium
Alexey Kopytov
5.6
Medium
Laurynas Biveinis

Bug Description

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.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.