[MDEV-15843] mysys: remove optimized memcpy from 18 years ago Created: 2018-04-11  Updated: 2018-05-07  Resolved: 2018-05-07

Status: Closed
Project: MariaDB Server
Component/s: Server
Fix Version/s: 10.3.7

Type: Task Priority: Major
Reporter: Sergey Vojtovich Assignee: Michael Widenius
Resolution: Fixed Votes: 0
Labels: contribution, foundation


 Description   

While this code has remained dormant for 18 years, libc implementers have used assembly features to gain improvements using architecture features optimized and by the buffer length like:

https://svnweb.freebsd.org/base/head/lib/libc/amd64/string/memcmp.S
https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/aarch64/memcmp.S
https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/powerpc/powerpc64/memcpy.S
While the perf results in commit message don't show a great improvement the varying length and codebase shows optimizations based on length.

Pull request: https://github.com/MariaDB/server/pull/698



 Comments   
Comment by Michael Widenius [ 2018-05-07 ]

Thanks a lot for the testing and results! Very interesting!

I don't want yet to remove the ptr_compare code as the results depends a lot on:

  • Size of strings and if strings are aligned
  • If the cpu allows unaligned access

There is some benefit in knowing the exact length and alignment in advance instead of doing the check for each call. However your tests shows that for our most common platform the libc memcmp is better and I agree we should use that.

I prefer to keep the old code around, as it's still possible to do a faster memcmp based on the principle of ptr_cmp. I will take your excellent patch comment and disable the ptr_cmp code for now in preference of the standard memcmp.
@montywi

Comment by Michael Widenius [ 2018-05-07 ]

Pushed

Generated at Thu Feb 08 08:24:27 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.