[cairo] ps optimization

Carl Worth cworth at cworth.org
Sat Mar 8 09:04:00 PST 2008

[Note: Charles' original "ps optimization" mail didn't make it to the
list due to an overly large attachment. I've quoted his entire message
for context, (and included a link to the large attachment).]

On Fri, 07 Mar 2008 18:53:55 -0800, Charles Doutriaux wrote:
> Hello
> I'm using 1.5.12 under Linux.
> I'm having difficutlies with cairo's postscript fallbacks...

Hi Charles,

Welcome. You've definitely come to the right place and I hope we can
help you.

> The attached code, although very long, is somewhat typical of the kind
> of plots our users generates (the actual code produces 6 figures like
> this one on the same page).

I've posted the C code (uncompressed this time---roughly 7 MB) here:


> The png output for this code, takes around a second.
> The postscript output takes around 30 minutes...
> The ps generated is 19MB!

Hmm... I'm not replicating those results. Here's what I see:

    $ gcc $(pkg-config --cflags --libs cairo) -o dump_cairo dump_cairo.c
    $ time ./dump_cairo
    real    2m4.201s
    user    1m15.120s
    sys     0m0.137s
    $ ls -l test.ps
    -rw-r--r-- 1 cworth cworth 3149850 2008-03-08 08:54 test.ps

So on my laptop it's only taking 2 minutes and only resulting in a
file of 3MB. This is with cairo recently from git, but glancing
through the logs since 1.5.12 I certainly don't see anything obvious
that would have changed the cairo-ps performance, (in either speed or
output size).

Or are the differences I'm seeing entirely explained because the
example you sent only has 1 instead of 6 figures? A factor of 6 would
capture most of the difference.

> Somebody on this list already suggested once to use 24bit pattern.
> Unfortunately as this example shows it is not an option for us because
> we need the transparency thru these patterns...
> The time is somewhat an issue, but also the size of the ps generated...
> I think the ps driver still needs some optimization?

Quite likely. There's almost always more we can do. For example a
simple thing that might pay off is to tweak the printing of
floating-point number to not emit excessive digits, (I know this is
something that Adrian is planning on doing).

> Thanks for any suggestion,
> C>

I'm guessing that Adrian could look at this test case and come up with
several ideas that cairo could do to be more efficient.

Thanks very much for the test case, and I hope you have fun with cairo!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20080308/c0218deb/attachment.pgp 

More information about the cairo mailing list