You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Dave Thorn <da...@fysh.org> on 2012/11/08 10:23:21 UTC

Object reuse, and speeds

Hi,

I've seen in the documentation about reusing objects:

> Fop instances shouldn't (and can't) be reused. Please recreate
> Fop and FOUserAgent instances for each rendering run using the
> FopFactory. This is a cheap operation as all reusable information
> is held in the FopFactory. That's why it's so important to reuse
> the FopFactory instance.

But it seems that creating a newFop is a more expensive operation
than I was expecting:

FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out);

The 'newFop' call takes 600-700ms on my (not underpowered)
desktop.  I first started timing this after I'd made fonts
"work", so I've noticed that if I remove the font config from my
fop config file[1], or just empty my fonts directory, then newFop
takes 100-150ms.

I have only 8 font files in my fonts directory (arial and arial
narrow, bold/italic/underline versions).  The font cache is being
created, so I presume it is also being used.

Is there any way to improve this speed?  A lot of the
documentation on the web seems to relate to earlier versions and
I've seen it mentioned that the way I'm doing it is correct for
1.0 (I intend to move to 1.1 once it's in the central maven
repositories).

A 500ms delay might not seem like a lot, but I'm trying to
replace an existing application, so I have a metric the newapp
will be judged by, and 500ms before we even begin the transform
(currently ~1500ms on an incomplete document) seems to be
starting on the back foot.


Thanks,


[1] <renderers>
    <renderer mime="application/pdf">
      <fonts>

	<directory recursive="true">/home/davet/fop/1/fonts</directory>

      </fonts>
    </renderer>
  </renderers>

-- 
dave thorn

DBT; GBP.

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: Object reuse, and speeds

Posted by Dave Thorn <da...@fysh.org>.
On Thu, Nov 08, 2012 at 09:37:57AM +0000, Mehdi Houshmand wrote:
> 
[snip]
> try trunk and let me know if that helps; what you should find is that
> the first creation of the Fop object is as costly as it was before, but
> subsequent instantiations of the object shouldn't have as much of a
> performance impact.
> 
> Let me know if that does what you're looking for,

Actually, that helps without me having to checkout the trunk.

If I actually simulate more closely proper application behaviour
(i.e. create one fopFactory and create-and-use multiple Fop
objects) then for the subsequent Fop object creations the time
drops to ~40-60ms.

I should really have tried that first.  But thank you.

I will try to put off using 1.1 until it's in the central maven
repository.

-- 
dave thorn

Hi, I'm from the Internet.

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: Object reuse, and speeds

Posted by Mehdi Houshmand <me...@gmail.com>.
Hi Dave,

The problem here is several fold, firstly the "old" (and by that I mean
what was used in versions <= 1.1) had to configure the fonts in the fop
conf on each run (thus the need for a fonts-cache). However, we have put
some time into improving the performance of these mechanisms in trunk. I'd
say, try trunk and let me know if that helps; what you should find is that
the first creation of the Fop object is as costly as it was before, but
subsequent instantiations of the object shouldn't have as much of a
performance impact.

Let me know if that does what you're looking for,

Hope that helps,

Mehdi


On 8 November 2012 09:23, Dave Thorn <da...@fysh.org> wrote:

> Hi,
>
> I've seen in the documentation about reusing objects:
>
> > Fop instances shouldn't (and can't) be reused. Please recreate
> > Fop and FOUserAgent instances for each rendering run using the
> > FopFactory. This is a cheap operation as all reusable information
> > is held in the FopFactory. That's why it's so important to reuse
> > the FopFactory instance.
>
> But it seems that creating a newFop is a more expensive operation
> than I was expecting:
>
> FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
> Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out);
>
> The 'newFop' call takes 600-700ms on my (not underpowered)
> desktop.  I first started timing this after I'd made fonts
> "work", so I've noticed that if I remove the font config from my
> fop config file[1], or just empty my fonts directory, then newFop
> takes 100-150ms.
>
> I have only 8 font files in my fonts directory (arial and arial
> narrow, bold/italic/underline versions).  The font cache is being
> created, so I presume it is also being used.
>
> Is there any way to improve this speed?  A lot of the
> documentation on the web seems to relate to earlier versions and
> I've seen it mentioned that the way I'm doing it is correct for
> 1.0 (I intend to move to 1.1 once it's in the central maven
> repositories).
>
> A 500ms delay might not seem like a lot, but I'm trying to
> replace an existing application, so I have a metric the newapp
> will be judged by, and 500ms before we even begin the transform
> (currently ~1500ms on an incomplete document) seems to be
> starting on the back foot.
>
>
> Thanks,
>
>
> [1] <renderers>
>     <renderer mime="application/pdf">
>       <fonts>
>
>         <directory recursive="true">/home/davet/fop/1/fonts</directory>
>
>       </fonts>
>     </renderer>
>   </renderers>
>
> --
> dave thorn
>
> DBT; GBP.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
>
>