[texhax] Throughput

Heiko Oberdiek heiko.oberdiek at googlemail.com
Fri Mar 4 19:07:25 CET 2011

On Fri, Mar 04, 2011 at 12:37:54PM -0500, Peter Davis wrote:

> On Fri, Mar 4, 2011 at 12:28 PM, Heiko Oberdiek <
> heiko.oberdiek at googlemail.com> wrote:
> > On Fri, Mar 04, 2011 at 11:46:31AM -0500, William Adams wrote:
> >
> > > Will things be better in LuaTeX? Really, all one would need would be a
> > > list structure which one could check before loading a graphic to see if
> > it
> > > had already been loaded --- add it to the list if not and it ``just
> > > works''.
> >
> > Some things can be done better with and without LuaTeX,
> > some things can never be done better with or without LuaTeX,
> > and some things can be done better with LuaTeX.
> > Those "things" depend on the macro interface, the macro driver interface,
> > the output driver, the TeX compiler and the output format.
> >
> > If the same image is used twice you have also take into account,
> > how it is used. There are many parameters that influence the
> > image loading (width, height, scaling, rotating, clipping, viewport,
> > image manipulation options, ...). Some of the parameters can also
> > be applied on the black box where the image is previously saved.
> > Others require the reloading of the image. Of course, the set
> > of parameters might differ for different drivers and image types.
> >
> >
> There are two separate problems:
> 1) I want the image to be defined in an image XForm in the resulting PDF,
> and simply referenced each time it occurs.

I have done thus in package bmpsize (but that's does not support
XeTeX, because it uses \pdffiledump). Perhaps some of the code
in bmpsize-dvipdfmx.def can be ported to xetex.def.

> 2) I'd like the actual image file to be accessed as little as possible
> during the run of XeLaTeX, for performance reasons.
> In a run of 35,000 pages, such as my current test, it's likely I'll
> encounter more than 256 unique images, so using box registers will not help
> in general.  If I could identify the most frequently occurring images, I
> could use box registers for those but, alas, I have no way to do that
> without pre-processing the entire XML, and that's not an option.  I could
> simply use box registers for the first 256 images encountered in a run, and
> that may actually help in most cases.
> Also, as you point out, some of the images may be used multiple times, at
> different scales and or rotations.  This is pretty common with logos, for
> example.

With XeTeX you have eTeX that extends the number of box registers
to 32768, if you load package `etex' to extend LaTeX's allocation scheme.

An algorithm of reuse could be:
At first the image is put in a XForm with known size.
Different sizes/scales/rotations can be applied afterwards.
The key consists of the image file name. Parameters that cannot
be applied afterwards are added to the key. The XForm identification
can be remembered in a macro whose name contains the key with all
its components in a fixed order:
  \csname xform at file=myimage.png&paramA=valueA&paramB=valueB\endcsname

Yours sincerely
  Heiko Oberdiek

More information about the texhax mailing list