bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#57911: Abolish max-specpdl-size


From: Mattias Engdegård
Subject: bug#57911: Abolish max-specpdl-size
Date: Sun, 18 Sep 2022 13:57:22 +0200

This is a proposal to abolish max-specpdl-size, the user-controllable limit on 
the internal specpdl stack.

It is safe to do so because unbounded specpdl growth is not possible without 
proportionally growing the lisp-eval-depth. Therefore, max-lisp-eval-depth 
suffices as a guard against runaway recursion and unreasonable memory usage as 
it effectively bounds the specpdl stack as well.

The change would give us some performance benefits but the biggest gain is in 
user convenience: currently, any code that needs deeper recursion than 
permitted by default has to set two variables. What values to use is often a 
matter of puzzlement and guessing since it is far from clear to anyone how they 
relate.

Why abolish max-specpdl-size rather than max-lisp-eval-depth, if they are 
connected? First and foremost, because the lisp-eval-depth is easier to explain 
and understand; the specpdl is an internal implementation detail that most Lisp 
users don't really have a firm grip on.

Moreover, although each Lisp call currently consumes at least one specpdl 
entry, this won't necessarily remain true in the future: it should be possible 
to eliminate that specpdl usage for gains in both speed and memory. In that 
case, max-specpdl-size would no longer serve as an effective recursion limit.

Concretely, the change would amount to retaining max-specpdl-size as a plain 
dynamic Lisp variable with no special meaning. We could obsolete it or keep it 
around indefinitely. A patch will come -- it's all very straightforward.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]