[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Wed, 29 Aug 2018 02:31:35 -0700
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1
Stefan Monnier wrote:
I see integer-width is set to 65536, and NEWS mentions this var and what
is its effect, but I can't find any documentation for the reason behind
the existence of this variable nor the choice of its default value.
The manual says, "Setting this variable to zero disables creation of bignums;
setting it to a large number can cause Emacs to consume large quantities of
memory if a computation creates huge integers." Should this be expanded, and if
so, what's needed?
I chose 65536 in an attempt at a sensible compromise between values too small
(useful integers cannot be computed) and too large (Emacs thrashes). I didn't do
a full engineering analysis to come up with that number, and am not wedded to it.
would there be harm in setting it to most-positive-fixnum?
The harm would be that Emacs could thrash due to numeric computation (enabling
some DoS attacks).
While we're on the topic, there are some theoretical limits other than
integer-width. Integers can't contain more than most-positive-fixnum bits, not
only because integer-width is limited to a fixnum, but also because of other
internal limits within Emacs. Some internal limits are imposed by libgmp (e.g.,
integers can't contain more than ULONG_MAX bits, or more than INT_MAX *
ULONG_WIDTH bits). I didn't put this stuff into the documentation because these
are implementation details that we should hide from users and besides these
integers are so outlandishly large that Emacs will surely thrash before users
run into them.