If the file is being entirely pre-loaded, then I doubt that IO blocking is a
significant contributing factor to your test.

I think that the best clue here may be the difference between performance
with form flattening and without form flattening.  Just to confirm, am I
right in saying that iText outperforms the competitor by a significant
amount in the non-flattening scenario?  If that's the case, then it seems
like we should see significant differences in the profiling results between
the flattening and non-flattening scenarios in iText.

Would you be willing to post the profiling results for both cases so we can
see which code paths are consuming the most runtime in each?

Another possibility if the profiling results show similar hotspots is that
the form flattening algorithms in iText are using the hotspot areas a lot
more than in the non-flattening case.  There may be a bunch of redundant
reads or something in the flattening case.

Let's take a look at the profiling results and see if we can draw any
conclusions about where to go next.

BTW - which profiler are you using?  Are you able to expand each of the
hotspot code paths and see the actual call path that is causing the
bottleneck?  I use jvvm, and the results of expanding the hotspot call trees
can be quite illuminating.

What I really would like is to get ahold of your two benchmark tests (with
and without flattening) so I can run it on my system - do you have anything
you can package up and share?

- K


Giovanni Azua-2 wrote:
> 
> Hello,
> 
> On Apr 23, 2010, at 10:50 PM, trumpetinc wrote:
>> Don't know if it'll make any difference, but the way you are reading the
>> file
>> is horribly inefficient.  If the code you wrote is part of your test
>> times,
>> you might want to re-try, but using this instead (I'm just tossing this
>> together - there might be type-os):
>> 
>> ByteArrayOutputStream baos = new ByteArrayOutputStream();
>> byte[] buf = new byte[8092];
>> int n;
>> while ((n = is.read(buf)) >= 0) {
>>      baos.write(buf, 0, n);
>> }
>> return baos.toByteArray();
>> 
> I tried your suggestion above and made no significative difference
> compared to doing the loading from iText. The fastest I could get my use
> case to work using this pre-loading concept was by loading the whole file
> in one shot using the code below.
> 
> Applying the cumulative patch plus preloading the whole PDF using the code
> below, my original test-case now performs 7.74% faster than before,
> roughly 22% away from competitor now ...  
> 
> btw the average response time numbers I was getting:
> 
> - average response time of 77ms original unchanged test-case from the
> office multi-processor-multi-core workstation 
> - average response time of 15ms original unchanged test-case from home
> using my MBP
> 
> I attribute the huge difference between those two similar experiments
> mainly to having an SSD drive in my MBP ... the top Host spots reported
> from the profiler are related one way or another to IO so would be no
> wonder that with an SSD drive the response time improves by a factor of
> 5x. There are other differences though e.g. OS, JVM version.  
> 
> Best regards,
> Giovanni
> 
> private static byte[] file2ByteArray(String filePath) throws Exception {
>   InputStream input = null;   
>   try {
>     File file = new File(filePath);
>     input = new BufferedInputStream(new FileInputStream(filePath));
>               
>     byte[] buff = new byte[(int) file.length()];
>     input.read(buff);
> 
>     return buff;
>   }   
>   finally {
>     if (input != null) {
>       input.close();
>     }
>   }
> }  
> 
> 
> 
> ------------------------------------------------------------------------------
> 
> _______________________________________________
> iText-questions mailing list
> iText-questions@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/itext-questions
> 
> Buy the iText book: http://www.itextpdf.com/book/
> Check the site with examples before you ask questions:
> http://www.1t3xt.info/examples/
> You can also search the keywords list:
> http://1t3xt.info/tutorials/keywords/
> 

-- 
View this message in context: 
http://old.nabble.com/performance-follow-up-tp28322800p28352147.html
Sent from the iText - General mailing list archive at Nabble.com.


------------------------------------------------------------------------------
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to