Subject: Re: bug#45705: [feature/native-comp] Excessive memory consumption on windows 10

From: Andrea Corallo <[email-masked]>
Date: Fri, 08 Jan 2021 22:02:38 +0000

Eli Zaretskii <[email-masked]> writes:

>> From: Andrea Corallo <[email-masked]>
>> Cc: [email-masked], [email-masked]
>> Date: Fri, 08 Jan 2021 15:50:28 +0000
>>
>> consumptions of few GiB is something I've seen more then once for long
>> standing sessions.  You might be right in this being a memory leak,
>> indeed I've no prove of that (I think we have none for the other
>> direction either).
>
> I'm not yet worried about memory leaks, I'm more worried that there's
> no memory leaks, and instead using libgccjit indeed requires such
> large memory amounts.  Are you sure this is not the case?

I see,

if we are interested in comparing the memory footprint of using shared
libraries for functions vs stock byte-code I think we can "statically"
compare two sessions after the startup.

I've compiled current native-comp with and without --with-nativecomp
repeating the experiment with and without X.  These are the data-points:

  |         | --without-x | --without-x --with-nativecomp |      |
  |---------+-------------+-------------------------------+------|
  | -Q      | 49M         | 92M                           | 1.9x |
  | my-conf | 92M         | 179M                          | 1.9x |

  |         |      | --with-nativecomp |      |
  |---------+------+-------------------+------|
  | -Q      | 536M | 756M              | 1.4x |
  | my-conf | 585M | 1453M             | 2.4x |

So yes shared are using considerably more memory, I think this is
expected as also the file footprint suggests native code is less dense
that byte-code (actually with a quite similar relative results).

Indeed *with use the delta should decay as data are the same and there's
no difference in its representation*, so this picture should be more on
the worst case side than on the average.

Also if we want to see a positive side, multiple Emacs sessions will
share the majority the pages allocated for the shared libraries.

  Andrea