Re: First req.getParameter(String) in servlet horrible _slow_ ;-(

Benoit Mahe wrote:

> > A coworker found yesterday a nasty performance problem in jigsaw
> > (jigsaw 2.0.4 with Tomcat 3.1 M1):
> > A servlet receiving a large HTTP POST request consumes a lot CPU time
> > (in our case it needs ~2-3 secs) in the first
> > HttpServletRequest.getParameter() call.
> > Any idea where the problem sits and how to solve this (without buing a
> > UltraSPARC-4500 to power-out the problem =:-) ?
>
> Well, the parsing is done in org.w3c.jigsaw.forms.URLDecoder so the "problem" should
> sits there. But I don't see anything that could slow down the request handling, this should
> be a really really big POST! what's its size?

Uhm, don't know - AFAIK it has ~100 entries each ~30 bytes long (unencoded).

After seeking and travelling around the sources:
1. JigsawHttpServletRequest.java's prepareQueryParameters() request.getInputStream() may be
wrapped by a BufferedInputStream ...
2. What about using a BufferedReader in general within URLDecoder (which would obsoltete [1])
?
3. Is there a way to count the number of bytes in the stream (via req ?) ? Maybe it's possible
to calculate the size of  URLDecoder's "buffer" array (which would avoid some
reallocations)... !?
4. If [3] isn't possible, what about setting URLDecoder's "buffer" array to an initial size of
1024 bytes ?

Any comments ?

----


>
> (2 or 3 seconds just for parsing the body, that's a lot of time)

It's a stupid laptop with 166MHz and 48MB. BTW: Our 70MHz SPARCstation5 is few 1/10secs faster
(both JDK 1.2.x) =:-)

----

Bye,
Roland

--
  __ .  . __
 (o.\ \/ /.o) Roland.Mainz@informatik.med.uni-giessen.de
  \__\/\/__/  gisburn@informatik.med.uni-giessen.de
  /O /==\ O\  MPEG specialist, C&&JAVA&&Sun&&Unix programmer
 (;O/ \/ \O;) TEL +49 641 99-13193 FAX +49 641 99-41359

Received on Thursday, 6 April 2000 05:02:38 UTC