[erlang-questions] refactoring a very large record
Jesper Louis Andersen
Thu Oct 20 21:29:04 CEST 2011
On Thu, Oct 20, 2011 at 18:19, Matthew Sackman <> wrote:
> On Thu, Oct 20, 2011 at 12:14:20PM -0400, Jachym Holecek wrote:
>> And even if the analysis was feasible, updating values in-place means
>> you're introducing forward pointers on the heap (or pointers from old
>> generation to nursery even), which may complicate garbage collector.
> Even better than that, if you have done the analysis correctly, then in
> some cases, you could build the tuple on the stack, not the heap, and
> thus avoid going to the heap entirely for very short lived structures.
Even better than that, if you have done the analysis correctly, then
in some cases, you could avoid building the tuple, keeping values in
registers all along, and not on the stack, and thus avoid going to the
stack entirely for very short lived structures.
And yes, there are functional language compilers out there which are
really good at eliminating intermediate structure. Usually it is
easier if you have type information statically at your disposal.
Usually you have a representation pass which choose what kind of
representation in memory a structure is going to have, including
whether or not to represent it as the structure at all.
More information about the erlang-questions