[Mono-list] poor mysql performance under debian testing

Rainer Burgstaller rainer.burgstaller@web.de
Thu, 13 May 2004 09:45:04 +0200


Hello

I have an extremely weird problem. I have 2 linux installations on my machine. One is debian woody (upgraded to testing) and the other is suse linux 9.

Somehow it seems that under debian the mysql performance is 10x slower than on suse (where it runs just fine). 

I did a lot of investigation already but it seems that
a) the normal mono performance on debian is fine (see benchmark program below). Its even a bit better than on suse
b) the general mysql performance (without mono) seems to be equally good (tested with a simple perl DBI script)
c) as soon as the bytefx driver is used debian is 10x slower than suse



Here is the program I used to test it:

<snip>
using System;
using System.Text;
using System.Security.Cryptography;


using ByteFX.Data.MySqlClient;

namespace PerfTest
{
	class PerfTest
	{
		[STAThread]
		static void Main(string[] args)
		{
            DateTime start = DateTime.Now;
            Console.WriteLine("Starting test");
            Random rand = new Random();
            ASCIIEncoding ae = new ASCIIEncoding();
            
            for ( int i = 5; i < 10000; i++ ) {
                // generate random string with length of i
                byte[] buffer = new byte[i];
                rand.NextBytes(buffer);
                string toEncode = ae.GetString(buffer);
                string result = EncryptPassword(toEncode);
                if ( i%1000 == 0 ) 
                    Console.WriteLine("  - encoding {0}",i);
            }
            TimeSpan duration = DateTime.Now.Subtract(start);
            Console.WriteLine("Test took {0} ms",duration.TotalMilliseconds);
            
            // now start the mysql test 100 times
            start = DateTime.Now;
            for ( int i = 0; i < 100; i++ ) {
                Console.WriteLine("start mysql test #{0}",i);
                TestMySQL();
            }
            duration = DateTime.Now.Subtract(start);
            Console.WriteLine("complete mysql test took {0}",duration);
        }
		
		public static void TestMySQL() {
		    DateTime start = DateTime.Now;
		    
		    MySqlConnection conn = new MySqlConnection("server=127.0.0.1;database=database;User ID=user;Password=pass");
		    conn.Open();
		    MySqlCommand cmd = conn.CreateCommand();
		    cmd.CommandText = "SELECT * FROM nuke_users";
		    MySqlDataReader reader = cmd.ExecuteReader();
		    while (reader.NextResult()) {
		        for ( int i = 0; i < reader.FieldCount; i++ ) {
		            string result = reader[i].ToString();
		        }
		    }
		    cmd.Dispose();
		    conn.Close();
		    
		    TimeSpan duration = DateTime.Now.Subtract(start);
		    Console.WriteLine("  single mysql test took {0}",duration);
		}
		
        public static String EncryptPassword( String aPassword )
        {
            ASCIIEncoding ae = new ASCIIEncoding();
			
            byte[] data = ae.GetBytes(aPassword);

            
            MD5 md5 = new MD5CryptoServiceProvider();

            byte[] result = md5.ComputeHash(data);				
            String hashStr = "";
            
            for ( int i = 0 ; i < result.Length; i++ )
                hashStr += String.Format("{0:x}",result[i]);
            return hashStr;			    
        }
	}
}
</snip>

Results: 
Encoding test: suse 12,6 s ; debian 10,6s
single mysql test: suse: ~0,5s; debian ~5,5s
complete mysql tests: suse 55,4s, debian 9m11,8s

Here are some other details about my installations
* obviously, its always the same machine
* kernel versions: suse 2.4.21-99, debian 2.4.26-1
* file system: suse: reiser; debian: ext2
* I am using mono-0.91.tar.gz from www.go-mono.com and compiled it without any special options on both machines 
* mysql versions: suse 4.0.15, debian 4.0.18
* config files for mysql are the same
* mysql user: under suse its running as root, under debian its running under mysql
* both installations are more or less out of the box, this means only the basic packages installed which are needed to compile and run mono and mysql (mysql was installed from the package). Debian (as already stated) was upgraded to testing (change to testing in sources.list and do apt-get distupgrade).

I already posted a msg on mysqlnet.sf.net but nobody answered there. So this is my last resort.

Please help before I go absolutely mental!
_____________________________________________________________________
Der WEB.DE Virenschutz schuetzt Ihr Postfach vor dem Wurm Netsky.A-P!
Kostenfrei fuer alle FreeMail Nutzer. http://f.web.de/?mc=021157