POV-Ray : Newsgroups : povray.programming : #macro parsing speed (or the lack of it) : Re: #macro parsing speed (or the lack of it) Server Time
28 Jul 2024 16:15:21 EDT (-0400)
  Re: #macro parsing speed (or the lack of it)  
From: Thorsten Froehlich
Date: 10 Jan 2000 08:25:18
Message: <3879ddbe@news.povray.org>
In article <3878b696@news.povray.org> , Nieminen Juha 
<war### [at] punarastascstutfi>  wrote:

> Chris Colefax and I were discussing about improvements of the compressed mesh
> macros so that they could be easier to maintain and use. He noted that the
> parsing of #macros is so slow (specially when #included from an external file)
> that he is not using them in many places where speed is needed. This of course
> causes some serious problems in modularity and usability.

It is possible to improve the speed of macros, but it requires quite a few
changes if it is done right.

> Why #macros are so slow specially when #included?

This is the easiest question to answer. The key problem is in Invoke_Macro
and Return_From_Macro. When a macro is in another file POV-Ray opens and
closes that file _each_ time the macro is invoked. It not only does that,
but it also uses Locate_file to search for it each time (usually by trying
to open it in each directory). So first, if it is not in the first directory
POV-Ray searches for, this will waste some time. Now, when parsing the macro
is done, it will close the file again.

> Can this be improved?

There are several ways which when combined should give much better results.
The worst idea would be to leave all files with macros open as different
systems have different limits for the maximum number of open files. So a
compromise would be to cache for example the ten most frequently opened
files. This would probably give some improvement.

It could be even faster if frequently used parts of all files would also be
cached dynamically, at least for systems that don't offer a good disk cache.

It might also be worth looking into the symbol table stuff going on in there
in order to support local variables, but I don't know exactly how that part
of the code works.


       Thorsten


____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.