Karim BELABAS on Thu, 11 Mar 1999 13:01:13 +0100 (MET)


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

pari.el + GC


[Paul van Wamelen: ]
[I'm not sure this was also sent to the list, but it raises interesting
topics, so...]
> I (just quickly) tried the new pari.el and so far it looks good. At
> least the things that bugged me are gone.
> 
> ? \s
> [...]
>  Occupation of the PARI stack :   0.00 percent
> [...]
> 
> "\s" always gives me 0.00 percent of the stack used, even after all
> kinds of computations.

That's how it should be. Permanent things go to heap. Stack is non-permanent
scratch space: after returning to the prompt all of it should have been given
back. The \s format is a legacy of old times when history was cluttering
the stack (so that you had to restart GP after a number of computations...).
It is now mostly useless (when debugging, the underlying routine can be
useful).

You can use print(getstack()) in the middle of your computation, it will tell
you how much garbage the _analyzer_ has accumulated (not much usually). \gm 2
is much more useful, because it tells you where and when important garbage
collecting is occuring, mostly in the library routines this time.

[Garbage Collecting in PARI is messy to use in library mode, but very
efficient: since things are not allocated in a complicated way, garbage is
freed simply by moving the stack pointer. Sometimes things have to be shifted
around, but all in all, about 1 or 2% of total user time is used up by the
(primitive...) GC engine. Of course if the stack is too large, there may be a
problem with swap and cache, hence it may be better to work with a _small_
stack. Well relatively small, 40MB, say; if things don't fit in there,
chances are that GC is not being done properly (unless the input data is
"huge" of course...)]

   Karim.
--
Karim Belabas                    email: Karim.Belabas@math.u-psud.fr
Dep. de Mathematiques, Bat. 425
Universite Paris-Sud             Tel: (00 33) 1 69 15 57 48
F-91405 Orsay (France)           Fax: (00 33) 1 69 15 60 19
--
PARI/GP Home Page: http://hasse.mathematik.tu-muenchen.de/ntsw/pari/