[metapost] memory problem

Stephan Hennig mailing_list at arcor.de
Sun May 7 12:32:11 CEST 2006

Denis.Roegel at loria.fr schrieb:

>> Is it possible that Stephan's task requires more than 1000
>> unknowns? Or I haven't caught the problem?
> Stefan's initial (and perhaps non realistic) example had more than
> 2500 unknowns.

Just for clarity: In mail "[metapost] [metaobj] performance leak with
boxes" I sent an example with n=40 boxes. The delayed version runs
noticeably slower on my 2,4 GHz machine. In the bug report I sent Denis
I had n=100 boxes. Hence, the 2500 variables as Denis pointed out. I
appended the original bug report to this mail.

Stephan Hennig

Date: Fri, 28 Apr 2006 22:07:40 +0200
From: Stephan Hennig <stephanhennig at arcor.de>
To: Denis Roegel <Denis.Roegel at loria.fr>
Subject: [bug] metaobj: boxes with rbox_radius > 0

Hi Denis,

it seems another bug has come to my attention. :-) I've already posted
that on the MetaPost mailing list on 2006-4-14 but didn't find response

When drawing boxes with _rounded_ corners there seems to be a massive
performance leak. Just run the sample code. On my 2,4 GHz machine the
code runs minutes where a simple change in the ordering of instructions
makes the code run only seconds.

Two macros are defined in the code. Both build a number of boxes and
place them randomly. They differ in that macro drawImmediately builds,
locates and draws one box after the other, while macro drawDelayed first
builds all boxes and then in a second loop locates and draws them. The
latter macro is _much_, _much_ slower if and only if rbox_radius is set
to a positive value.

Unfortunately, when drawing trees I need untied boxes and can't tie them
first as a workaround. Since the performance leak is noticeable even
when using a moderate number of rounded boxes this is a very annoying issue.

Stephan Hennig

input metaobj
prologues := 1;
numeric node[];

def drawImmediately(expr n) =
  for i:=1 upto n:
    newBox.node[i](decimal i);
    node[i].c = (uniformdeviate 300bp, uniformdeviate 300bp);

def drawDelayed(expr n) =
  for i:=1 upto n:
    newBox.node[i](decimal i);
  for i:=1 upto n:
    node[i].c = (uniformdeviate 300bp, uniformdeviate 300bp);

%   drawImmediately(100);

More information about the metapost mailing list