United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-8011234 : Performance regression with ftp protocol when uploading in image mode

Details
Type:
Bug
Submit Date:
2013-04-02
Status:
Resolved
Updated Date:
2013-04-19
Project Name:
JDK
Resolved Date:
2013-04-03
Component:
core-libs
OS:
Sub-Component:
java.net
CPU:
Priority:
P3
Resolution:
Fixed
Affected Versions:
7,8
Fixed Versions:

Related Reports
Backport:

Sub Tasks

Description
Hi,

A customer is reporting slow Ftp upload in Java 7, versus Java 6.

<<

In our application, we are using URL.openConnection() to open the FTP connection. We would like to know if there is a way to open the buffer Size as mentioned in the URL below or could we do something else to make the ??? java FTP??? file transfer faster ?

http://stackoverflow.com/questions/14000341/why-is-ftp-upload-slow-in-java-7"

>>

The last version tested that does not worked is 7u15. The version
that is working is 6u33.
Solaris 10

No testcase, but here is the snippet:

 URL lUrl = new URL(aInContextURL, aInFtpUrl);
lUrl.openConnection().getOutputStream();

wireshark snippet when using jdk_1.7.0_15  - BAD case

1205826    728.057224    135.121.1.171    135.121.1.60    FTP-DATA FTP Data: 220 bytes
1205827    728.059320    135.121.1.171    135.121.1.60    FTP-DATA FTP Data: 1460 bytes
1205828    728.059327    135.121.1.171    135.121.1.60    FTP-DATA FTP Data: 1 bytes
1205829    728.059331    135.121.1.60    135.121.1.171    TCP    51748 > 48997 [ACK] Seq=1 Ack=527417331 Win=49640 Len=0
1205830    728.059403    135.121.1.171    135.121.1.60    FTP-DATA FTP Data: 14 bytes
1205831    728.061662    135.121.1.171    135.121.1.60    FTP-DATA FTP Data: 1460 bytes
1205832    728.061668    135.121.1.171    135.121.1.60    FTP-DATA FTP Data: 1 bytes

1,205,871 packets to send  503M file using ftp

wireshark snippet when using jdk_1.6.0_33  -  GOOD case

50    0.197849    135.121.1.60    135.121.1.23    TCP    25616 > 53511 [ACK] Seq=1 Ack=10221 Win=49640 Len=0
51    0.197965    135.121.1.23    135.121.1.60    FTP-DATA    FTP Data: 1460 bytes
52    0.198089    135.121.1.23    135.121.1.60    FTP-DATA    FTP Data: 1460 bytes
53    0.198211    135.121.1.23    135.121.1.60    FTP-DATA    FTP Data: 1460 bytes
54    0.198334    135.121.1.23    135.121.1.60    FTP-DATA    FTP Data: 1460 bytes

397,919 packets to send  462M file using ftp


Seeking advice, pointers, further debugging tips.


Thank you,

Kim 
                                    

Comments
The ftp URL isn't included in the bug report but I'll bet it image/binary mode. For that case the updated ftp client returns the raw output stream whereas it used to return a TelnetOutputStream (which is buffered). This should fix it:

iff -r b4f68aca1000 -r c534937f6e94 src/share/classes/sun/net/ftp/impl/FtpClient.java
--- a/src/share/classes/sun/net/ftp/impl/FtpClient.java	Tue Apr 02 16:26:54 2013 -0700
+++ b/src/share/classes/sun/net/ftp/impl/FtpClient.java	Wed Apr 03 13:15:39 2013 +0100
@@ -1299,16 +1299,16 @@
      *         <code>null</code> if the command was unsuccessful.
      * @throws IOException if an error occured during the transmission.
      */
-    public OutputStream putFileStream(String name, boolean unique) throws sun.net.ftp.FtpProtocolException, IOException {
+    public OutputStream putFileStream(String name, boolean unique)
+        throws sun.net.ftp.FtpProtocolException, IOException
+    {
         String cmd = unique ? "STOU " : "STOR ";
         Socket s = openDataConnection(cmd + name);
         if (s == null) {
             return null;
         }
-        if (type == TransferType.BINARY) {
-            return s.getOutputStream();
-        }
-        return new sun.net.TelnetOutputStream(s.getOutputStream(), false);
+        boolean bm = (type == TransferType.BINARY);
+        return new sun.net.TelnetOutputStream(s.getOutputStream(), bm);
     }
 
     /**



                                     
2013-04-02
URL:   http://hg.openjdk.java.net/jdk8/tl/jdk/rev/c534937f6e94
User:  alanb
Date:  2013-04-03 12:20:41 +0000

                                     
2013-04-03
URL:   http://hg.openjdk.java.net/jdk8/jdk8/jdk/rev/c534937f6e94
User:  lana
Date:  2013-04-16 20:41:41 +0000

                                     
2013-04-16



Hardware and Software, Engineered to Work Together