Change of buffer size in ShapeZipOutputFormat
---------------------------------------------
Key: GEOS-2121
URL: http://jira.codehaus.org/browse/GEOS-2121
Project: GeoServer
Issue Type: Improvement
Components: WFS
Affects Versions: 1.6.4
Environment: Irrelevant
Reporter: Albin Lundmark
Assignee: Andrea Aime
Fix For: 1.6.5
I have corrected a method in ShapeZipOutputFormat (in package
org.geoserver.wfs.response) that makes the shape-zip output format more than 10 times faster. Especially for large shape-zip outputs.
The new code looks like this and it would be nice if it could be corrected in the next release:
/**
* readInWriteOutBytes Description: Reads in the bytes from the input stream
* and writes them to the output stream.
*
* @param output
* @param in
*
* @throws IOException
*/
private void readInWriteOutBytes(OutputStream output, InputStream in) throws IOException {
int c;
byte buffer = new byte[1024 * 1024];
while (-1 != (c = in.read(buffer))) {
output.write(buffer, 0, c);
}
}
(In the current trunk version the method reads one byte at the time which seems inefficient by nature and possibly even worse when writing to a ZipOutputStream.)
The above buffer size is not optimized and propably does not need to be that big as Andrea Aime stated in out conversation on the geoserver-users list:
"- have you tested with a smaller buffer, such as 4KB? That's
the size I usually use for file reads, my experience is that
speedups go down very steeply after that size. A buffer of
one meg has the side effect of visibly limiting the number
of concurrent clients that can issue such a request (we already
have WMS which is very memory hungry by nature), so I'd check
with different sizes and see what's the speedup for each,
trying to find a balance between single user speed and memory
consuption."
I have not yet tested any other buffer size than the one above.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira