emacs-devel
[Top][All Lists]
Advanced

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

Re: `aset` on strings, changing the size in bytes


From: Stefan Monnier
Subject: Re: `aset` on strings, changing the size in bytes
Date: Sun, 09 Sep 2018 20:18:04 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

>> >> The need for an indirection (a String_Object has to hold a pointer to an
>> >> sdata object rather than being able to keep its payload directly in the
>> >> Lisp_String object (using FLEXIBLE_ARRAY_MEMBER))
>> > Why is that a problem?
>> It slows down every string access, and increases the heap size of every
>> string (currently they're something like N bytes of payload plus
>> 5 words where 2 of those 5 words are due to the extra indirection).
>> For a feature that's almost never used, I think it's pretty costly.
> It can be (and was) used by memory-allocation infrastructure,
> especially with very large strings.  Are we sure we want to lose it
> for slowdown that should be hardly perceptible?

As mentioned in my original message, this indirection is used currently
for 2 purposes:
1- to implement `aset`.
2- to implement string compaction in the GC.

For this reason, either one of the two may be considered to "come for
free" if you presume the other one as a given.

Point nb 2 is a purely internal implementation detail, which we
could change whenever we feel like this decision gets in the way of
something preferable.

Point nb 1 OTOH cannot be changed so easily because it would be
a backward-incompatible change.


        Stefan




reply via email to

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