List:General Discussion« Previous MessageNext Message »
From:Joe Kislo Date:January 6 2006 2:17am
Subject:~75% performance drop upgrading from Mysql 4.0 to 5.0
View as plain text  
Here are the timings:

64-bit 5.0 Single Thread 1:00:12.17 total (~76% slower)
64-bit 4.1 Single Thread 41:38.07 total (~20% slower)
64-bit 4.0 Single Thread 34:50.23 total

	I have been trying to get a stable configuration for a 64-bit mysql on
ubuntu for the past 6-8 months, and have developed a number of stress
tests to try to isolate problems.  I've been able to successfully
discover several bugs in MySQL (or libc) running in 64-bit mode.  I've
recently started running these tests against 4.1 and 5.0 versions of
MySQL, but I have discovered very very different performance
characteristics compared to MySQL 4.0.  

	For this test, it imports one of our customer databases, records the
import time, drops the database, and restarts.  I've run this test
against the 4.0, 4.1 and 5.0 binaries.  I've found a *dramatic*
performance drop on the 4.1 and 5.0 lines against the 4.0 line of MySQL
when executing this test.  The tests and configurations are identical.
This test may be lopsided (insert + alter table enable keys), however it
is something that we actually do daily in our production environment.
If we were to consider upgrading our production environment from 4.0 to
5.0, a 75% drop in performance would not be acceptable for these types
of operations.

	I ran these tests for a minimum of 24 hours each (although there was
very little variance between the 1st and the last run).  Each
installation was a fresh mysql binary installation, with newly built
grant tables (EG: blank).  The machine is a 2-cpu 2.4GHz Opteron 4GB
Memory with a 4 disc RAID 0+1 array, running Ubuntu Breezy.  I ran these
tests against the 32-bit version for each of those versions, and saw
similar timings, except on average they were 11% slower than their
corresponding 64-bit version.  I also ran these tests with two threads,
(operating on separate databases), and found similar performance hits
with MySQL 4.1 and 5.0 and an overall 17% drop in performance against
single threaded operation.

All my.cnf files were identical between the versions, except that I
changed the datadir and language settings (to point to the appropriate
directory).  I have attached the my.cnf file.  I am using MyISAM tables
for all tests.

The test harness is very simple:

while true; do
      echo "create database $1"
| /var/lib/mysql/mysql-standard-5.0.17-linux-x86_64-glibc23/bin/mysql -u
      time zcat TEST_DATABASE.mysql.gz
| /var/lib/mysql/mysql-standard-5.0.17-linux-x86_64-glibc23/bin/mysql -u
root $1
      echo "drop database $1"
| /var/lib/mysql/mysql-standard-5.0.17-linux-x86_64-glibc23/bin/mysql -u

I thought perhaps MySQL 5.0 may be doing a better job determining index
cardinalities than 4.0, and as a result there would be no need to do an
optimize-db after an insert.  I modified the test to insert the
database, then optimize each of the tables.  I discovered the same test
execution time (MySQL 5.0 ~75% slower) and MySQL 4.0 was able to
optimize the tables 20% faster.

Although I cannot provide our customer data, I can show you an example
of what the import file looks like:

  userID int(11) NOT NULL default '0',
  roleID int(11) NOT NULL default '0',
  aiFilter int(11) default NULL,
  PRIMARY KEY  (userID,roleID)

-- Dumping data for table `ABCState`


the dump was generated from a mysqldump -l --add-locks --extended-insert
--quick --all --disable-keys.  There are millions of records, the
compressed GZ file is 500 megs.  There is a good array of varchar, char,
blob fields across 100+ tables.

Does anybody have any idea why 5.0 is performing so poorly?  Since I am
not using any of the new 4.1 or 5.0 features, I would have expected my
performance to be similar between versions.  I thought originally that
performance may have suffered starting in 4.1 because of the
localization overhead, but 5.0 has a much more dramatic performance
drop.  Are there any settings I should tweak?  We do not have any plans
to use any of the new features in 4.1 or 5.0.


# The MySQL database server configuration file.
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "/var/lib/mysql/my.cnf" to set server-specific options or
# - "~/.my.cnf" to set user-specific options.
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.

# This will be passed to all mysql clients
# It has been reported that passwords should be enclosed with ticks/quotes
# escpecially if they contain "#" chars...
#password	= my_password
port		= 3306
socket		= /var/run/mysqld/mysqld.sock

# Here is entries for some specific programs
# The following values assume you have at least 32M ram

# This was formally known as [safe_mysqld]. Both versions are currently parsed.
socket		= /var/run/mysqld/mysqld.sock
nice		= 0

user		= mysql
pid-file	= /var/run/mysqld/
socket		= /var/run/mysqld/mysqld.sock
port		= 3306
# Both location gets rotated by the cronjob.
log-error		= /var/log/mysql/mysql.err
#log		= /var/log/mysql.log
#log		= /var/log/mysql/mysql.log
basedir		= /usr
datadir		= /var/lib/mysql/mysql-standard-5.0.17-linux-x86_64-glibc23/data
tmpdir		= /var/lib/mysql/tmp
language	= /var/lib/mysql/mysql-standard-5.0.17-linux-x86_64-glibc23/share/mysql/english
# The skip-networking option will no longer be set via debconf menu.
# You have to manually change it if you want networking i.e. the server
# listening on port 3306. The default is "disable" - for security reasons.

key_buffer		= 512M
tmp_table_size		= 1024M
max_connections		= 2000
max_connect_errors	= 999999999
table_cache		= 1024
myisam_sort_buffer_size	=512M
join_buffer_size	=512M
sort_buffer		=512M
#low-priority-updates    =TRUE

max_allowed_packet	= 16M
thread_stack		= 128K

# Query Cache Configuration
query_cache_limit	= 1M
query_cache_size        = 256M
query_cache_type        = 1

# Here you can see queries with especially long duration
log-slow-queries	= /var/log/mysql/mysql-slow.log
# The following can be used as easy to replay backup logs or for replication
#server-id		= 1
#log-bin		= /var/log/mysql/mysql-bin.log
#binlog-do-db		= include_database_name
#binlog-ignore-db	= include_database_name
# Read the manual if you want to enable InnoDB!
# Read the manual, too, if you want chroot!
# chroot = /var/lib/mysql/
# If you want to enable SSL support (recommended) read the manual or my
# HOWTO in /usr/share/doc/mysql-server/SSL-MINI-HOWTO.txt
# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem

max_allowed_packet	= 16M

#no-auto-rehash	# faster start of mysql but no tab completition

key_buffer		= 16M
~75% performance drop upgrading from Mysql 4.0 to 5.0Joe Kislo6 Jan