Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DAFB6112D2 for ; Thu, 7 Aug 2014 19:41:18 +0000 (UTC) Received: (qmail 77313 invoked by uid 500); 7 Aug 2014 19:41:13 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 77225 invoked by uid 500); 7 Aug 2014 19:41:13 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 77213 invoked by uid 99); 7 Aug 2014 19:41:13 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Aug 2014 19:41:13 +0000 Date: Thu, 7 Aug 2014 19:41:13 +0000 (UTC) From: "Bernd Eckenfels (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (NET-550) Default FTPClient bufferSize results in very slow retrieve transfers MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/NET-550?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Bernd Eckenfels updated NET-550: -------------------------------- Attachment: (was: net-buffercopy.patch) > Default FTPClient bufferSize results in very slow retrieve transfers > -------------------------------------------------------------------- > > Key: NET-550 > URL: https://issues.apache.org/jira/browse/NET-550 > Project: Commons Net > Issue Type: Bug > Affects Versions: 3.3 > Reporter: Geoffrey Hardy > Attachments: net-buffercopy.patch > > > While experimenting with FTPClient, I discovered that if I don't call setBufferSize(), the default value is zero. This results in retrieveFile() calling the version of InputStream.read() with no parameters, reading one byte at a time. For comparison, the downloading a CD ISO image of about ~648MB took 18m10s with the default settings. In contrast, calling setBufferSize(8192) took only 7.9s, an improvement of ~137x. > Here is some sample code: > {code:java} > FTPClient ftp = new FTPClient(); > // ftp.setBufferSize(8192); > ftp.setControlKeepAliveTimeout(300); > ftp.setCopyStreamListener(new CopyStreamListener() { > @Override > public void bytesTransferred(long totalBytesTransferred, int bytesTransferred, long streamSize) { > System.out.println("totalBytesTransferred: " + totalBytesTransferred > + ", bytesTransferred: " + bytesTransferred + ", streamSize: " + streamSize); > } > @Override public void bytesTransferred(CopyStreamEvent event) {} > }); > ftp.connect(host); > ftp.login(user, pass); > ftp.retrieveFile(file, outputStream); > {code} > The log message from the stream listener printed lots messages "bytesTransferred: 1" and totalBytesTransferred incremented by 1 each time. This corresponds to the part of the code which reads one byte at a time with {{int inputStream.read()}}. -- This message was sent by Atlassian JIRA (v6.2#6252)