[Mono-list] poor mysql performance under debian testing
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: 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 < 1; 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; } } } 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 ___ Mono-list maillist - [E
RE: [Mono-list] how to do proper role based authentication in web apps
> Check this article: > > Part 1: > http://www.ondotnet.com/pub/a/dotnet/2004/02/02/effectiveformsauth.html > Part 2: http://www.ondotnet.com/pub/a/dotnet/2004/02/16/formsauthpt2.html Thanks for the response. Actually, part1 is what I came up myself and part2 is just a slight improvement. Still there is the issue that the formsauthenticationmodule will first intercept the cookie, set one "dummy" principal and then my piece of code overrides that. This is not really elegant. I was actually looking for something like this membership stuff however, it does not seem to be implemented yet. So I guess I will integrate the stuff from part2 and stick to it for the moment until the new features are implemented in mono. By the way there is a difference in the mono implementation and microsofts. When I set the HttpContext.CurrentUser (I dont know the syntax by heart) the Thread.CurrentPrincipal is not updated in mono but in Ms .NET it is. So currently for mono I have to set both to the principal I want to use. Otherwise the permission stuff wont work. thanks for the hints Verschicken Sie romantische, coole und witzige Bilder per SMS! Jetzt neu bei WEB.DE FreeMail: http://freemail.web.de/?mc=021193 ___ Mono-list maillist - [EMAIL PROTECTED] http://lists.ximian.com/mailman/listinfo/mono-list
[Mono-list] RE: poor mysql performance under debian testing
What I don't understand is why you have this problem depending on the distribution, maybe in SuSE you have the lastest bytefx code installed already? No, that is not possible since I downloaded the sourcecode to mono-0.91 on both platforms and compiled it there. I dont use the suse rpms. I will try the mysqlnet stuff on the weekend maybe it helps. thanks for the suggestion ___ Mono-list maillist - [EMAIL PROTECTED] http://lists.ximian.com/mailman/listinfo/mono-list
Re: [Mono-list] poor mysql performance under debian testing
Hi Sergio The code that comes with Mono is very very slow, but you can download the lastest bytefx code from "http://sourceforge.net/projects/mysqlnet/"; and you will see it is very fast. I tried this now on the weekend and you were right. The 0.76 is approx 50 times faster on the debian machine as the one which comes with mono. It seems that mono delivers an ancient version of mysqlnet. Now I have approx. the same speed on both suse and debian. Its even a lot faster than the old version was on suse. I cannot really understand why mono still bundles this old version (even though beta1 has just arrived when I tried it so I thought mysqlnet would be up to date aswell). thanks for the suggestion. I already spent a lot of hours on this issue. cheers - Rainer ___ Mono-list maillist - [EMAIL PROTECTED] http://lists.ximian.com/mailman/listinfo/mono-list
[Mono-list] Is PrincipalPermissionAttribute working?
Hi It seems that the PrincipalPermissionAttribute is not working as expected (at least not as I expect it :) I checked the class status and it says 100% so I guess this means that it should work. I got the following code which works just nice under MS.NET. [PrincipalPermissionAttribute(SecurityAction.Demand, Role="root")] public void UpdateMember( Member aMember ) { // do something secret here :) } When Thread.CurrentPrincipal.IsInRole("root") is false then under windows this raises a SecurityException (which I think is correct). However, under mono-0.91 it runs through without any problem (i.e. does not generate the exception). I verified this by modding the code above to [PrincipalPermissionAttribute(SecurityAction.Demand, Role="root")] public void UpdateMember( Member aMember ) { IPrincipal princ = System.Threading.Thread.CurrentPrincipal; bool adminRole = princ.IsInRole("root"); if ( !adminRole ) throw new Exception("You dont belong to the admins. Go away"); // do something very secret here } The modified code raises now the exception. So here are the two options a) I dont understand how to use PrincipalPermissionAttribute (which could easily be true) b) the mono implementation does not work as expected. Can anybody help me? ___ Mono-list maillist - [EMAIL PROTECTED] http://lists.ximian.com/mailman/listinfo/mono-list
Re: [Mono-list] Is PrincipalPermissionAttribute working?
Hello Sebastien Thanks for the quick reply. So what would be the quickest alternative? Would this work? void MySecretFunction() { PrincipalPermission permission = new PrincipalPermission(null,"root",true); permission.Demand(); // do something secret here } The PrincipalPermission class is implemented but Mono doesn't (and won't) support security attributes in 1.0. See bugzilla entry #52693 for more details. cheers ___ Mono-list maillist - [EMAIL PROTECTED] http://lists.ximian.com/mailman/listinfo/mono-list
[Mono-list] mod_mono and SSL
Hi I have been looking in the lists archives and could not find a clear answer if I can run mod_mono now under my SSL domain or not. I have mod_mono successfully running on debian under my http site. But when I remove it from the http site and put the lines into the virtualhost section of the https site it does not work. here is a snippet of my virtual host configuration. SNIP ServerAdmin [EMAIL PROTECTED] ServerName secure.dummy.com DocumentRoot /www/secure-web SSLEngine on SSLCertificateKeyFile /etc/apache2/ssl/server.key SSLCertificateFile /etc/apache2/ssl/server.crt SSLCipherSuite bla... Options FollowSymLinks AllowOverride None Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all Alias /mono "/www/mono" MonoApplications "/mono:/www/mono" SetHandler mono ... ENDSNIP So I would like to know: a) does mono under SSL work at all? (maybe I am trying in vain for now) b) if yes, whats wrong? regards ___ Mono-list maillist - [EMAIL PROTECTED] http://lists.ximian.com/mailman/listinfo/mono-list
Re: [Mono-list] mod_mono and SSL
Hi Gonzalo thanks for the quick reply. I now changed it according to your template but it still does not work. Although, it looks better now (i.e. mod-mono-server.exe is now started) I still dont get a reply. It might be important to mention that I am using apache2. Here is my current configuration: Listen 443 ServerAdmin [EMAIL PROTECTED] ServerName webmail.foo.com DocumentRoot /share/secure-web SSLEngine on SSLCertificateKeyFile /etc/apache2/ssl/server.key SSLCertificateFile /etc/apache2/ssl/server.crt SSLCipherSuite bar Alias /mono "/share/secure-web/mono" MonoApplications "/mono:/share/secure-web/mono" MonoPath "/usr/local/lib/mono/1.0:/usr/local/lib/mono/2.0" MonoExecutablePath "/usr/local/bin/mono" MonoServerPath "/usr/local/bin/mod-mono-server.exe" SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all SetHandler mono ErrorLog /var/log/apache2/secure-error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /var/log/apache2/secure-access.log combined ServerSignature On When I do lynx https://localhost/mono I get Alert!: Unexpected network read error; connection aborted. Is there any way to get a log from mono? Maybe somethings crashing there? any suggestions? -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/ ___ Mono-list maillist - [EMAIL PROTECTED] http://lists.ximian.com/mailman/listinfo/mono-list
[Mono-list] how to do proper role based authentication in web apps
Hi I have a question on how to properly do RBA in web applications. I am currently using the formsauthentication but it only supports fixed users stored in the web.config file which is pretty inflexible (am I missing something)? So what I currently do is to override the Thread.CurrentPrincipal and HttpContext.User by the user which is stored in the cookie (which I also create by hand). I do that in the global.asax. I checked a few open source projects (omniportal, Rainbow) on how they do it but it does not seem like they do it too good either (I dont mean to insult anyone). I am coming from the java side and there JAAS offers a quite elegant way of doing such a thing by using "plugin" authentication providers. So I wondered if there is such a possibility or if I could somehow replace the FormsAuthenticationModule by something I do which then allows authentication agains a db for example. any suggestions? ___ Mono-list maillist - [EMAIL PROTECTED] http://lists.ximian.com/mailman/listinfo/mono-list
Re: [Mono-list] how to do proper role based authentication in web apps
On Fri, 4 Jun 2004 16:20:16 +1000, Peter Foley <[EMAIL PROTECTED]> wrote: Have a look at the Microsoft MSDN site. There is a document there about the Providers pattern which is used in ASP.NET 2 for a membership class. It is very straightforward to write your own membership class that uses a provider e.g. a sql database to store rol info. Hello Peter thanks for the quick reply. I think I found the article you mean (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/bucupro.asp). Is this functionality already supported by mono / xsp /mod_mono? I had a quick look at SqlMembershipProvider.cs in mono-0.91 but there all functions threw the notimplementedexception. So I guess the answer is no. Or is the framework already in place to place in my own MembershipProvider? Also from a quick glance on the document I am not sure how to integrate it. Do I still use the FormsAuthenticationModule or not? ___ Mono-list maillist - [EMAIL PROTECTED] http://lists.ximian.com/mailman/listinfo/mono-list
[Mono-list] Problem using p/invoke on mono 1.0.1
Hi First of all here is my configuration Debian testing (quite up to date) Mono-1.0.1 (got the mono-1.0.1.tar.gz) I am trying to use libcrypt.so.2.3.2 with c#. This code has been working for quite a while but stopped to work now. here is a little sample program I wrote using System; using System.Text; using System.Security.Cryptography; using System.Web.Security; using System.Runtime.InteropServices; namespace CryptTest { class CryptTest { [DllImport ("crypt", EntryPoint="crypt", SetLastError=true)] private static extern string UnixCrypt(string text, string salt); [STAThread] static void Main(string[] args) { Console.WriteLine("have {0} args",args.Length); string arg = args[0]; Console.WriteLine("UnixEncrypting {0} : {1}",arg,UnixCrypt(arg,arg)); } } } When I try to run this with mono encrypt.exe rainer I get a NullReference Exception. I am a bit lost here since this code has been working beautifully for months. Either my debian upgraded its libcrypt version (which could easily be true) or upgrading to mono-1.0.1 introduced the problem (which is less likely since I remember having the same issue on mono-1.0). Here is a snipped of the trace .. . ENTER: (wrapper managed-to-native) PerfTest.PerfTest:UnixCrypt (string,string)([STRING:0x80f8fc0:rainer], [STRING:0x80f8fc0:rainer], ) .. . . ENTER: (wrapper managed-to-native) System.Object:__icall_wrapper_mono_string_to_utf8 (object)([STRING:0x80f8fc0:rainer], ) .. . . LEAVE: (wrapper managed-to-native) System.Object:__icall_wrapper_mono_string_to_utf8 (object)result=135946400 .. . . ENTER: (wrapper managed-to-native) System.Object:__icall_wrapper_mono_string_to_utf8 (object)([STRING:0x80f8fc0:rainer], ) .. . . LEAVE: (wrapper managed-to-native) System.Object:__icall_wrapper_mono_string_to_utf8 (object)result=135941976 .. . . ENTER: (wrapper managed-to-native) System.Object:__icall_wrapper_mono_string_new_wrapper (intptr)(0x41350540, ) .. . . LEAVE: (wrapper managed-to-native) System.Object:__icall_wrapper_mono_string_new_wrapper (intptr)[System.String:0x80ef988] .. . . ENTER: (wrapper managed-to-native) System.Object:__icall_wrapper_g_free (intptr)(0x41350540, ) .. . . . ENTER: (wrapper runtime-invoke) System.Object:runtime_invoke_void (object,intptr,intptr,intptr)([System.NullReferenceException:0x80f07b0], (nil), (nil ), 0x413583d8, ) .. . . . . ENTER: System.NullReferenceException:.ctor ()(this:0x80f07b0[System.NullReferenceException encrypt.exe], ) .. . . . . . ENTER: Locale:GetText (string)([STRING:0x80f3c78:A null value was found where an object instance was required.], ) .. . . . . . LEAVE: Locale:GetText (string)[STRING:0x80f3c78:A null value was found where an object instance was required.] .. . . . . LEAVE: System.NullReferenceException:.ctor () .. . . . LEAVE: (wrapper runtime-invoke) System.Object:runtime_invoke_void (object,intptr,intptr,intptr)[OBJECT:(nil)] EXCEPTION handling: NullReferenceException I checked /usr/include/crypt.h again to make sure that there is not a new version with different headers. But the function is still here here is a snip of crypt.h /* Encrypt at most 8 characters from KEY using salt to perturb DES. */ extern char *crypt (__const char *__key, __const char *__salt) __THROW; so to me everything looks still fine but still it does not work. Can anyone help? ___ Mono-list maillist - [EMAIL PROTECTED] http://lists.ximian.com/mailman/listinfo/mono-list
[Mono-list] Re: Problem using p/invoke on mono 1.0.1
> The work-around for this is to have your method return an > IntPtr and then > convert the IntPtr to a string manually. For example, use the > following in > the place of your WriteLine() statement: > > string encrypted = Marshal.PtrToStringAnsi(UnixCrypt(arg,arg)); > Console.WriteLine("UnixEncrypting {0} : {1}",arg,encrypted); Thanks a lot!!! That worked. ___ Mono-list maillist - [EMAIL PROTECTED] http://lists.ximian.com/mailman/listinfo/mono-list