tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Re: Code performance question #2
Date Tue, 08 Aug 2006 08:49:27 GMT

David Kerber wrote:
> Pid wrote:
>> here's another obvious question:
>> if you're in a servlet, and you're getting an & separated string from
>> somewhere, where is the "somewhere" that you're getting it from?
>> does the servlet activate and collection the data somehow, or does the
>> data get sent to the servlet (in, for example the query string)?
> The data is sent via an HTTP POST request, with the query string lightly
> encrypted.

if it's sent to the servlet using a POST, is there anything wrong with
using the hreq.getParameterNames() & hreq.getParameter("param_name")

Why encrypt the query string when you could just use an SSL connection
and encrypt the pipe? (Ignore this Q if you don't have control of the
other end).

>> Peter Crowther wrote:
>>>> From: David Kerber [] Is there a more
>>>> efficient "split" method I could use?  Or am I completely missing
>>>> the point of what you are suggesting?
>>> I think you've slightly missed the point.  I assume you're calling
>>> your function 5 times, each with a different field name that you want
>>> out of it.  You're then invoking string handling functions on the
>>> entire decrypted string 5 times, each time going through the bytes to
>>> extract the piece you need.  In the process, you traverse bytes you
>>> don't need several times.  My suggestion is that you tokenise this
>>> *once*, and hence only pay the string-handling overhead once.  Then
>>> you get all the parameters out of the same tokenised version.
>>> However, if the next thing you do is to write this to disk, I am even
>>> more convinced that you're optimising the wrong piece of code as the
>>> disk I/O is likely to take vastly more instructions than the string
>>> parse.
>>> These may be naïve questions, but I'll ask them anyway.  How have you
>>> identified these two pieces of code as the targets for optimisation? 
>>> What profiler have you used, under what conditions?  What proportion
>>> of your overall CPU budget is taken by these two snippets of code? 
>>> Is the machine CPU-bound in the first place, or is the bottleneck
>>> elsewhere?  If these are the worst culprits in your app, I'll be very
>>> surprised.
>>>         - Peter
> ---------------------------------------------------------------------
> To start a new topic, e-mail:
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message