Page 1 of 1

The WordprocessingMLPackage load file is extremely slow

PostPosted: Tue Sep 28, 2010 11:54 am
by Jingmeifan
When I use DOCX4J to manipulate the docx file, the line
wordMLPackage = WordprocessingMLPackage.load(file)
takes me 45 seconds to finish. This is unacceptable for users. :cry: Do you have a good way to reduce the time? Please response as soon as possible.

Thanks in advance,
Jane

Re: The WordprocessingMLPackage load file is extremely slow

PostPosted: Tue Sep 28, 2010 12:13 pm
by jason
Not my experience. The JAXB context does take a while to initialise (owing to the complexity of the OpenXML schemas) - on my Windows machine about 5 sec - but that is a one-off operation per execution of docx4j. (ie do it once, process many docx)

Code: Select all
28.09.2010 11:03:05 *INFO * Context: loading Context jc (Context.java, line 73)
28.09.2010 11:03:10 *INFO * Context: loaded com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl .. loading others .. (Context.java, line 78)
28.09.2010 11:03:10 *INFO * Context: .. others loaded .. (Context.java, line 91)


So, more info pls ... turn on logging for org.docx4j.jaxb.Context .. and tell us whether it is the loading of Context, or your document.

Are you experiencing your problem with one particular document, or all documents? If it is a particular document, you could post it here (rename to .zip). Does it contain a lot of images? There is an option for lazy loading of these, which might help.

What is the execution environment? Operating system, RAM, and CPU. How much memory are you allocating to the JVM (-xmx etc).

Re: The WordprocessingMLPackage load file is extremely slow

PostPosted: Tue Sep 28, 2010 12:58 pm
by Jingmeifan
Thanks Jason for your swift responding and so many valuable suggestion. My .docx file is very simple, no image there, the original one is .doc format, I re-save it to docx file. Is it causing problem? My Operating system is Windows XP, RAM 1.96, Intel(R) Core (TM)2 Duo CPU. And how to do lazy loading?

Thanks again,
Jane

Re: The WordprocessingMLPackage load file is extremely slow

PostPosted: Tue Sep 28, 2010 2:08 pm
by jason
Your computer should be fine. Ctrl-Alt-Del to look at RAM and processor utilisation prior to starting docx4j, and during it. Make sure the JVM has enough RAM (-xmx etc).

If your computer is ok, you can post your document (renamed as .zip), or email it to me, and I'll take a look at it.

Re lazy loading: If there are no images, there is nothing to lazy load.

Re: The WordprocessingMLPackage load file is extremely slow

PostPosted: Wed Sep 29, 2010 1:17 am
by Jingmeifan
Yes, you are right, the first time loading is very slow, after that, only 0.281 seconds to pass the line. :)
I monitor the CPU of my computer, it's not more 60% utilization to process docx4j at the first time, so I am still wondering, why the file takes so long at the initialization. I already attached the file in your email so that you take a look for me. Sorry about forgot to give subject in the email. ;)

Thanks,
Jane

Re: The WordprocessingMLPackage load file is extremely slow

PostPosted: Wed Sep 29, 2010 4:26 am
by Jingmeifan
I test the app under JBoss server, the execution time is much faster than develop mode, so I don't need worry about this any more. :)

Thanks for so many help,
Jane

Re: The WordprocessingMLPackage load file is extremely slow

PostPosted: Wed Sep 29, 2010 8:05 am
by jason
Great. Out of interest, when you say "develop mode", what is that, exactly? Is it in an IDE, and if so which one?

Re: The WordprocessingMLPackage load file is extremely slow

PostPosted: Wed Sep 29, 2010 12:14 pm
by Jingmeifan
Jetty is embedded in our app so that our changes are easily reflect to the page. SO we use Jetty for fast deployment and development. That's why during this period as develop mode. :)

Re: The WordprocessingMLPackage load file is extremely slow

PostPosted: Sat Jul 28, 2012 12:46 am
by risto45
Hi,

I'm experiencing the same problem.
"WordprocessingMLPackage.load(file)" line takes more than 30 seconds, although the loaded file is really small (13kb). Only one A4.
I'm using Tomcat 6.0.32.

I used to get java.lang.OutOfMemoryError, but when I increased Java heap space to 1024MB, it disappeared and docx file processing works.
But it is really slow.

I have Windows 7 and 4GB of RAM.

Can anyone help or say what else can I try?

Best regards,
Risto

Re: The WordprocessingMLPackage load file is extremely slow

PostPosted: Sat Jul 28, 2012 8:38 am
by jason
risto45 wrote:I used to get java.lang.OutOfMemoryError, but when I increased Java heap space to 1024MB, it disappeared and docx file processing works.
But it is really slow.

I have Windows 7 and 4GB of RAM.


Is this running from within your IDE, or a command line?

What CPU?

You've allocated Java 1024MB, but is that physical memory available (ie not in use by other apps)? Have a look at Windows Task Manager > Performance

Re: The WordprocessingMLPackage load file is extremely slow

PostPosted: Sat Jul 28, 2012 7:57 pm
by risto45
I'm running it within IDE and through browser (Firefox) - both are slow.
But I also now discovered that it is only slow first time I load the file. After that it is OK.
So every time I restart Tomcat, the first load is really slow.

CPU is Intel Core i7 M640 @ 2.80GHz

I have 4GB of RAM and approx 2GB is available - so that's not an issue.

Br,
Risto

Re: The WordprocessingMLPackage load file is extremely slow

PostPosted: Sun Jul 29, 2012 9:11 am
by jason
risto45 wrote:But I also now discovered that it is only slow first time I load the file. After that it is OK.


Yes, that's JAXB context init :-(

But it shouldn't take 30 seconds with that CPU. Less than 10, I'd think. Seems you have a bottleneck somewhere. Maybe disk thrashing as tomcat starts from within the IDE, or overhead due to IDE debugger?

Try running Tomcat standalone.