DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG� RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://issues.apache.org/bugzilla/show_bug.cgi?id=32546>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND� INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=32546 Summary: GET performance slow on large files Product: Slide Version: Nightly Platform: PC OS/Version: Linux Status: NEW Severity: normal Priority: P3 Component: WebDAV Server AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] We deal with Very Large Objects in our archive, and the hard-coded 2k buffer size in org/apache/slide/webdav/method/GetMethod.java was killing read performance. Getting a single chunk of data from our archive is a bit expensive, so I implemented a better buffering scheme (with a still hard-coded limit). Unified diff is below. On my local machine, I went from ~115KB/sec reads to ~9MB/sec reads for large objects. --- GetMethod.java.~1.55.~ 2004-11-09 10:00:28.000000000 -0500 +++ GetMethod.java 2004-12-03 22:13:09.000000000 -0500 @@ -70,8 +70,11 @@ // -------------------------------------------------------------- Constants - protected final int BUFFER_SIZE = 2048; + /** The default buffer size */ + protected final int DEFAULT_BUFFER_SIZE = 2048; + /** The maximum buffer size */ + protected final int MAX_BUFFER_SIZE = 200 * 1024; /** @@ -393,7 +396,7 @@ (resourceInputStream, input); // Copy the input stream to the output stream - exception = copyRange(istream, ostream); + exception = copyRange(istream, ostream, resourceInfo.length); // Clean up the input and output streams try { @@ -544,11 +547,12 @@ * @return Exception which occured during processing */ private IOException copyRange(InputStream istream, - ServletOutputStream ostream) { + ServletOutputStream ostream, + long resourceLength) { // Copy the input stream to the output stream IOException exception = null; - byte buffer[] = new byte[input]; + byte buffer[] = new byte[getBufferSize(resourceLength)]; int len = buffer.length; while (true) { try { @@ -591,7 +595,7 @@ IOException exception = null; long bytesToRead = end - start + 1; - byte buffer[] = new byte[input]; + byte buffer[] = new byte[getBufferSize(bytesToRead)]; int len = buffer.length; while ( (bytesToRead > 0) && (len >= buffer.length)) { try { @@ -615,6 +619,16 @@ } + /** + * Get a reasonable buffer size. + */ + private int getBufferSize(long resourceLength) + { + if (resourceLength <= 0) + return DEFAULT_BUFFER_SIZE; + + return (int)Math.min(resourceLength, MAX_BUFFER_SIZE); + } /** * Parse the range header. -- Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug, or are watching the assignee. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
