Bill Allombert on Tue, 01 Apr 2014 17:38:52 +0200


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

dynamic pari stack


Dear PARI-dev,

I have added a new default "parisizemax" to allow the stack to grow dynamically.

How does that works:
- if parisizemax=0, then nothing change. 
- otherwise the stack size will double automatically when needed,
  up to parisizemax.

A warning is displayed:

  *** Warning: increasing stack size to 16000000.

Advantages:
 Only the amount of stack actually needed for a computation is used,
 and the user can still limit the amount of memory used by GP
 programs (to prevent bugs in programs to crash the system by using
 all the memory).
 On systems allowing to overcommit memory, it is possible to set 
 parisizemax to a very large value, since only the used stack will be
 actually allocated in memory.

Further works:
- Add support for mmap: this is a much nicer alternative to overcommit.
  In particular this will allow to reduce the stack size to free some
  memory.
- Allow the user more control of what to do in case of stack overflow
  (instead of just doubling and continue)

COMPAT note:
  - top and bot are replaced by pari_mainstack->top and pari_mainstack->bot.
  - allocatemem() is replaced by paristack_resize.

Cheers,
Bill.