List:Commits« Previous MessageNext Message »
From:rburnett Date:November 1 2007 2:57pm
Subject:Connector/NET commit: r1049 - in branches/5.1: . Driver/Source
View as plain text  
Modified:
   branches/5.1/CHANGES
   branches/5.1/Driver/Source/MySqlStream.cs
   branches/5.1/Driver/Source/NativeDriver.cs
Log:
sped up LOAD DATA LOCAL INFILE dramatically by bypassing the normal stream processing code in MySqlStream

Modified: branches/5.1/CHANGES
===================================================================
--- branches/5.1/CHANGES	2007-10-31 21:26:19 UTC (rev 1048)
+++ branches/5.1/CHANGES	2007-11-01 14:57:10 UTC (rev 1049)
@@ -94,7 +94,8 @@
     using case insensitive semantics and this causes cases where a user orginally
     used the wrong case for a user id and then fixed it to still get access denied
     errors. (Bug #31433) 
-                
+  - improved the speed of load data local infile significantly   
+                  
 Version 5.0.8  8/16/2007
   Bug #28706 Log messages are truncated  
   - Fixed a problem with compression over a network.  We were letting the inflate stream read

Modified: branches/5.1/Driver/Source/MySqlStream.cs
===================================================================
--- branches/5.1/Driver/Source/MySqlStream.cs	2007-10-31 21:26:19 UTC (rev 1048)
+++ branches/5.1/Driver/Source/MySqlStream.cs	2007-11-01 14:57:10 UTC (rev 1049)
@@ -212,7 +212,16 @@
             }
 		}
 
-		/// <summary>
+        public void SendEntirePacketDirectly(byte[] buffer, int count)
+        {
+            buffer[0] = (byte)(count & 0xff);
+            buffer[1] = (byte)((count >> 8) & 0xff);
+            buffer[2] = (byte)((count >> 16) & 0xff);
+            buffer[3] = sequenceByte++;
+            baseStream.Write(buffer, 0, count + 4);
+        }
+
+        /// <summary>
 		/// StartOutput is used to reset the write state of the stream.
 		/// </summary>
 		public void StartOutput(ulong length, bool resetSequence)

Modified: branches/5.1/Driver/Source/NativeDriver.cs
===================================================================
--- branches/5.1/Driver/Source/NativeDriver.cs	2007-10-31 21:26:19 UTC (rev 1048)
+++ branches/5.1/Driver/Source/NativeDriver.cs	2007-11-01 14:57:10 UTC (rev 1049)
@@ -565,25 +565,21 @@
         /// <param name="filename"></param>
         private void SendFileToServer(string filename)
         {
-            byte[] buffer = new byte[4092];
+            byte[] buffer = new byte[8196];
             FileStream fs = null;
 
+            long len = 0;
             try
             {
                 fs = new FileStream(filename, FileMode.Open);
-                stream.StartOutput((ulong) fs.Length, false);
-
-                long len = fs.Length;
+                len = fs.Length;
                 while (len > 0)
                 {
-                    int count = fs.Read(buffer, 0, 4092);
-                    stream.Write(buffer, 0, count);
+                    int count = fs.Read(buffer, 4, (int)(len > 8192 ? 8192 : len));
+                    stream.SendEntirePacketDirectly(buffer, count);
                     len -= count;
                 }
-
-                // write the terminating packet
-                stream.SendEmptyPacket();
-                stream.Flush();
+                stream.SendEntirePacketDirectly(buffer, 0);
             }
             catch (Exception ex)
             {

Thread
Connector/NET commit: r1049 - in branches/5.1: . Driver/Sourcerburnett1 Nov