GNU bug report logs - #45705
[feature/native-comp] Excessive memory consumption on windows 10

Previous Next

Package: emacs;

Reported by: Édouard Debry <edouard.debry <at> gmail.com>

Date: Wed, 6 Jan 2021 20:49:01 UTC

Severity: normal

Merged with 45751

Done: Andrea Corallo <akrl <at> sdf.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 45705 in the body.
You can then email your comments to 45705 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#45705; Package emacs. (Wed, 06 Jan 2021 20:49:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Édouard Debry <edouard.debry <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 06 Jan 2021 20:49:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Édouard Debry <edouard.debry <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: [feature/native-comp] Excessive memory consumption on windows 10
Date: Wed, 06 Jan 2021 21:48:37 +0100
Hello,

On windows 10, I noticed that emacs could use a lot of memory, up 
to 6Go and
sometimes more. The memory consumption goes up and down from time 
to time while
I am not running any specific program in emacs, apart `lsp-java`

As my personal computer has 16Go of RAM, I can afford 
it. Unfortunately, my work
computer has much less and the whole compute completely freezes at 
one point
when using emacs.

I did not notice that behavior on linux. I do not know if the 
master branch has
the same problem. What could be the problem ?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#45705; Package emacs. (Wed, 06 Jan 2021 20:56:02 GMT) Full text and rfc822 format available.

Message #8 received at 45705 <at> debbugs.gnu.org (full text, mbox):

From: Andrea Corallo <akrl <at> sdf.org>
To: Édouard Debry <edouard.debry <at> gmail.com>
Cc: 45705 <at> debbugs.gnu.org
Subject: Re: bug#45705: [feature/native-comp] Excessive memory consumption
 on windows 10
Date: Wed, 06 Jan 2021 20:55:35 +0000
Édouard Debry <edouard.debry <at> gmail.com> writes:

> Hello,
>
> On windows 10, I noticed that emacs could use a lot of memory, up to
> 6Go and
> sometimes more. The memory consumption goes up and down from time to
> time while
> I am not running any specific program in emacs, apart `lsp-java`
>
> As my personal computer has 16Go of RAM, I can afford
> it. Unfortunately, my work
> computer has much less and the whole compute completely freezes at one
> point
> when using emacs.
>
> I did not notice that behavior on linux. I do not know if the master
> branch has
> the same problem. What could be the problem ?

Hi Édouard,

AFAIK was never proved recently Emacs garbage collector is failing to
recall memory, so I guess this is just some Lisp program that is
allocating a lot of memory keeping then those objects referenced.

Others may have more detaliled info about.

  Andrea




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#45705; Package emacs. (Thu, 07 Jan 2021 14:26:02 GMT) Full text and rfc822 format available.

Message #11 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Andrea Corallo <akrl <at> sdf.org>
To: Andrea Corallo via "Bug reports for GNU Emacs, the Swiss army knife of
 text editors" <bug-gnu-emacs <at> gnu.org>
Cc: Édouard Debry <edouard.debry <at> gmail.com>,
 45705 <at> debbugs.gnu.org
Subject: Re: bug#45705: [feature/native-comp] Excessive memory consumption
 on windows 10
Date: Thu, 07 Jan 2021 14:25:26 +0000
Andrea Corallo via "Bug reports for GNU Emacs, the Swiss army knife of
text editors" <bug-gnu-emacs <at> gnu.org> writes:

> Édouard Debry <edouard.debry <at> gmail.com> writes:
>
>> Hello,
>>
>> On windows 10, I noticed that emacs could use a lot of memory, up to
>> 6Go and
>> sometimes more. The memory consumption goes up and down from time to
>> time while
>> I am not running any specific program in emacs, apart `lsp-java`
>>
>> As my personal computer has 16Go of RAM, I can afford
>> it. Unfortunately, my work
>> computer has much less and the whole compute completely freezes at one
>> point
>> when using emacs.
>>
>> I did not notice that behavior on linux. I do not know if the master
>> branch has
>> the same problem. What could be the problem ?
>
> Hi Édouard,
>
> AFAIK was never proved recently Emacs garbage collector is failing to
> recall memory, so I guess this is just some Lisp program that is
> allocating a lot of memory keeping then those objects referenced.
>
> Others may have more detaliled info about.
>
>   Andrea
>

IOW I believe this is a duplicate of bug#43389.  Should we merge these?

  Andrea




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#45705; Package emacs. (Thu, 07 Jan 2021 14:26:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#45705; Package emacs. (Fri, 08 Jan 2021 14:26:02 GMT) Full text and rfc822 format available.

Message #17 received at 45705 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Andrea Corallo <akrl <at> sdf.org>
Cc: edouard.debry <at> gmail.com, 45705 <at> debbugs.gnu.org
Subject: Re: bug#45705: [feature/native-comp] Excessive memory consumption on
 windows 10
Date: Fri, 08 Jan 2021 16:25:45 +0200
> Date: Wed, 06 Jan 2021 20:55:35 +0000
> Cc: 45705 <at> debbugs.gnu.org
> From: Andrea Corallo via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
> 
> > On windows 10, I noticed that emacs could use a lot of memory, up to
> > 6Go and
> > sometimes more. The memory consumption goes up and down from time to
> > time while
> > I am not running any specific program in emacs, apart `lsp-java`
> >
> > As my personal computer has 16Go of RAM, I can afford
> > it. Unfortunately, my work
> > computer has much less and the whole compute completely freezes at one
> > point
> > when using emacs.
> >
> > I did not notice that behavior on linux. I do not know if the master
> > branch has
> > the same problem. What could be the problem ?
> 
> Hi Édouard,
> 
> AFAIK was never proved recently Emacs garbage collector is failing to
> recall memory, so I guess this is just some Lisp program that is
> allocating a lot of memory keeping then those objects referenced.

IME, 6 GiB is too much for any Lisp program to explain away.

Also, the memory allocator we use on Windows is known to return memory
to the OS more than glibc on GNU/Linux.  I have never seen my Emacs
session get anywhere near 1 GiB, let alone more, and my sessions run
for many weeks without restarting.

Can you tell what kind of memory footprints you see on your system
with the native-comp branch, after running the session for several
days or more?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#45705; Package emacs. (Fri, 08 Jan 2021 15:51:02 GMT) Full text and rfc822 format available.

Message #20 received at 45705 <at> debbugs.gnu.org (full text, mbox):

From: Andrea Corallo <akrl <at> sdf.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: edouard.debry <at> gmail.com, 45705 <at> debbugs.gnu.org
Subject: Re: bug#45705: [feature/native-comp] Excessive memory consumption
 on windows 10
Date: Fri, 08 Jan 2021 15:50:28 +0000
Eli Zaretskii <eliz <at> gnu.org> writes:

>> Date: Wed, 06 Jan 2021 20:55:35 +0000
>> Cc: 45705 <at> debbugs.gnu.org
>> From: Andrea Corallo via "Bug reports for GNU Emacs,
>>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>> 
>> > On windows 10, I noticed that emacs could use a lot of memory, up to
>> > 6Go and
>> > sometimes more. The memory consumption goes up and down from time to
>> > time while
>> > I am not running any specific program in emacs, apart `lsp-java`
>> >
>> > As my personal computer has 16Go of RAM, I can afford
>> > it. Unfortunately, my work
>> > computer has much less and the whole compute completely freezes at one
>> > point
>> > when using emacs.
>> >
>> > I did not notice that behavior on linux. I do not know if the master
>> > branch has
>> > the same problem. What could be the problem ?
>> 
>> Hi Édouard,
>> 
>> AFAIK was never proved recently Emacs garbage collector is failing to
>> recall memory, so I guess this is just some Lisp program that is
>> allocating a lot of memory keeping then those objects referenced.
>
> IME, 6 GiB is too much for any Lisp program to explain away.
>
> Also, the memory allocator we use on Windows is known to return memory
> to the OS more than glibc on GNU/Linux.  I have never seen my Emacs
> session get anywhere near 1 GiB, let alone more, and my sessions run
> for many weeks without restarting.
>
> Can you tell what kind of memory footprints you see on your system
> with the native-comp branch, after running the session for several
> days or more?

Hi Eli,

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).

Assuming it's a bug I don't see a priori why this should be a different
one respect the one reported for master.

Regards

  Andrea




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#45705; Package emacs. (Fri, 08 Jan 2021 16:11:02 GMT) Full text and rfc822 format available.

Message #23 received at 45705 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Andrea Corallo <akrl <at> sdf.org>
Cc: edouard.debry <at> gmail.com, 45705 <at> debbugs.gnu.org
Subject: Re: bug#45705: [feature/native-comp] Excessive memory consumption
 on windows 10
Date: Fri, 08 Jan 2021 18:10:00 +0200
> From: Andrea Corallo <akrl <at> sdf.org>
> Cc: edouard.debry <at> gmail.com, 45705 <at> debbugs.gnu.org
> 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?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#45705; Package emacs. (Fri, 08 Jan 2021 22:03:02 GMT) Full text and rfc822 format available.

Message #26 received at 45705 <at> debbugs.gnu.org (full text, mbox):

From: Andrea Corallo <akrl <at> sdf.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: edouard.debry <at> gmail.com, 45705 <at> debbugs.gnu.org
Subject: Re: bug#45705: [feature/native-comp] Excessive memory consumption
 on windows 10
Date: Fri, 08 Jan 2021 22:02:38 +0000
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Andrea Corallo <akrl <at> sdf.org>
>> Cc: edouard.debry <at> gmail.com, 45705 <at> debbugs.gnu.org
>> 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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#45705; Package emacs. (Sat, 09 Jan 2021 07:57:02 GMT) Full text and rfc822 format available.

Message #29 received at 45705 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Andrea Corallo <akrl <at> sdf.org>
Cc: edouard.debry <at> gmail.com, 45705 <at> debbugs.gnu.org
Subject: Re: bug#45705: [feature/native-comp] Excessive memory consumption
 on windows 10
Date: Sat, 09 Jan 2021 09:56:16 +0200
> From: Andrea Corallo <akrl <at> sdf.org>
> Cc: edouard.debry <at> gmail.com, 45705 <at> debbugs.gnu.org
> Date: Fri, 08 Jan 2021 22:02:38 +0000
> 
> 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).

Thanks for the data points.

What about memory usage when there's a background compilation of Lisp
going on?  GCC is known to be a memory hog in some cases, so I wonder
what happens in this case with libgccjit.

(Do we allow multiple async compilations, btw? if so, how many
concurrent compilations can be running, and how do we or the user
control that?)

Also, what are the numbers for a session that has been running for
several days?  I understand that it would be hard for you to collect
such numbers about all the configurations, but could you show the
growth of the configuration you are routinely using, which I presume
is --with-x --with-nativecomp and with your config?  As your numbers
above show, it starts at 1.5 GiB, but what is the footprint after a
day or a week?

> 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.

That's why I asked to see the memory footprint after the session has
run for some time, yes.

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

Assuming those sessions run the same binary of Emacs, yes.  Otherwise,
only some of them will be shared, the ones that are in common public
directories, and even that only if the running Emacsen are of the same
version.  Most of the shared code is in the pdumper file, btw, which
is outside of the picture for the purposes of this discussion.

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#45705; Package emacs. (Sat, 09 Jan 2021 10:56:01 GMT) Full text and rfc822 format available.

Message #32 received at 45705 <at> debbugs.gnu.org (full text, mbox):

From: Andrea Corallo <akrl <at> sdf.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: edouard.debry <at> gmail.com, 45705 <at> debbugs.gnu.org
Subject: Re: bug#45705: [feature/native-comp] Excessive memory consumption
 on windows 10
Date: Sat, 09 Jan 2021 10:55:23 +0000
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Andrea Corallo <akrl <at> sdf.org>
>> Cc: edouard.debry <at> gmail.com, 45705 <at> debbugs.gnu.org
>> Date: Fri, 08 Jan 2021 22:02:38 +0000
>> 
>> 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).
>
> Thanks for the data points.
>
> What about memory usage when there's a background compilation of Lisp
> going on?  GCC is known to be a memory hog in some cases, so I wonder
> what happens in this case with libgccjit.

In June we changed the way we store immediate objects in the shared and
this makes the compilation way lighter on the GCC side (both in time and
memory).  I've no precise data on this other than the experimental
observation that compiling all Elisp files in Emacs on 32bit systems is
not anymore an issue.  This IIUC implies that the memory footprint for
each compilation is always < 2GB.

As a note: in all cases except bootstrap the final pass (the one driving
libgccjit) is executed as a sub-process, this to protect us from
eventual GCC leaks and not to generate unnecessary fragmentation.  In
async compilation we indeed run all the compilation (also the Lisp
computation) in the child process, so compiling should not have impact
on the memory footprint of the main Emacs session.

> (Do we allow multiple async compilations, btw? if so, how many
> concurrent compilations can be running, and how do we or the user
> control that?)

Yes see <http://akrl.sdf.org/gccemacs.html#org91858b2>

> Also, what are the numbers for a session that has been running for
> several days?  I understand that it would be hard for you to collect
> such numbers about all the configurations, but could you show the
> growth of the configuration you are routinely using, which I presume
> is --with-x --with-nativecomp and with your config?  As your numbers
> above show, it starts at 1.5 GiB, but what is the footprint after a
> day or a week?

ATM I can provide this number, this is an Aarch64 daemon compiled with
'--without-x' with an up-time of 25 days and is showing a footprint of
765M.

>> 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.
>
> That's why I asked to see the memory footprint after the session has
> run for some time, yes.

The hard part is to have a reference to compare against as the memory
footprint is strictly connected to the usage.  One with very regular
working habits should work like one week on vanilla and one week on
native-comp to make a comparison.  I've no regular working habits so I
fear I'm not the best fit for this comparison.

Thanks

  Andrea





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#45705; Package emacs. (Sat, 09 Jan 2021 11:56:02 GMT) Full text and rfc822 format available.

Message #35 received at 45705 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Andrea Corallo <akrl <at> sdf.org>
Cc: edouard.debry <at> gmail.com, 45705 <at> debbugs.gnu.org
Subject: Re: bug#45705: [feature/native-comp] Excessive memory consumption
 on windows 10
Date: Sat, 09 Jan 2021 13:55:08 +0200
> From: Andrea Corallo <akrl <at> sdf.org>
> Cc: edouard.debry <at> gmail.com, 45705 <at> debbugs.gnu.org
> Date: Sat, 09 Jan 2021 10:55:23 +0000
> 
> > What about memory usage when there's a background compilation of Lisp
> > going on?  GCC is known to be a memory hog in some cases, so I wonder
> > what happens in this case with libgccjit.
> 
> In June we changed the way we store immediate objects in the shared and
> this makes the compilation way lighter on the GCC side (both in time and
> memory).  I've no precise data on this other than the experimental
> observation that compiling all Elisp files in Emacs on 32bit systems is
> not anymore an issue.  This IIUC implies that the memory footprint for
> each compilation is always < 2GB.

You assume that the compilations are all done serially?  AFAIK, most
people build Emacs with "make -jN", so parallel compilation is an
important use case.

I guess we will have to collect the information about that, if you say
we don't have it now.

> As a note: in all cases except bootstrap the final pass (the one driving
> libgccjit) is executed as a sub-process, this to protect us from
> eventual GCC leaks and not to generate unnecessary fragmentation.  In
> async compilation we indeed run all the compilation (also the Lisp
> computation) in the child process, so compiling should not have impact
> on the memory footprint of the main Emacs session.

That's fine, but the memory footprint of such a subprocess is also of
interest, as it could be relevant to the overall memory pressure of
the OS, and thus indirectly on the parent Emacs process as well.

> > (Do we allow multiple async compilations, btw? if so, how many
> > concurrent compilations can be running, and how do we or the user
> > control that?)
> 
> Yes see <http://akrl.sdf.org/gccemacs.html#org91858b2>

Thanks.  This needs further tuning, IMO, both per the FIXME
(i.e. provide a primitive to return the number of execution units),
and wrt the default value being half of the available units.  We
should pay attention to the system's load average as well, I think.

> > Also, what are the numbers for a session that has been running for
> > several days?  I understand that it would be hard for you to collect
> > such numbers about all the configurations, but could you show the
> > growth of the configuration you are routinely using, which I presume
> > is --with-x --with-nativecomp and with your config?  As your numbers
> > above show, it starts at 1.5 GiB, but what is the footprint after a
> > day or a week?
> 
> ATM I can provide this number, this is an Aarch64 daemon compiled with
> '--without-x' with an up-time of 25 days and is showing a footprint of
> 765M.

OK, thanks.

> The hard part is to have a reference to compare against as the memory
> footprint is strictly connected to the usage.  One with very regular
> working habits should work like one week on vanilla and one week on
> native-comp to make a comparison.  I've no regular working habits so I
> fear I'm not the best fit for this comparison.

I agree, these numbers still need to be collected.  Maybe we should
ask on emacs-devel that people who use the branch report their
numbers?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#45705; Package emacs. (Sat, 09 Jan 2021 12:38:02 GMT) Full text and rfc822 format available.

Message #38 received at 45705 <at> debbugs.gnu.org (full text, mbox):

From: Andrea Corallo <akrl <at> sdf.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: edouard.debry <at> gmail.com, 45705 <at> debbugs.gnu.org,
 Kévin Le Gouguec <kevin.legouguec <at> gmail.com>
Subject: Re: bug#45705: [feature/native-comp] Excessive memory consumption
 on windows 10
Date: Sat, 09 Jan 2021 12:37:54 +0000
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Andrea Corallo <akrl <at> sdf.org>
>> Cc: edouard.debry <at> gmail.com, 45705 <at> debbugs.gnu.org
>> Date: Sat, 09 Jan 2021 10:55:23 +0000
>> 
>> > What about memory usage when there's a background compilation of Lisp
>> > going on?  GCC is known to be a memory hog in some cases, so I wonder
>> > what happens in this case with libgccjit.
>> 
>> In June we changed the way we store immediate objects in the shared and
>> this makes the compilation way lighter on the GCC side (both in time and
>> memory).  I've no precise data on this other than the experimental
>> observation that compiling all Elisp files in Emacs on 32bit systems is
>> not anymore an issue.  This IIUC implies that the memory footprint for
>> each compilation is always < 2GB.
>
> You assume that the compilations are all done serially?  AFAIK, most
> people build Emacs with "make -jN", so parallel compilation is an
> important use case.

Yeah, we can say this loose information is only a per compilation unit
upper-bound.

> I guess we will have to collect the information about that, if you say
> we don't have it now.

I'm adding in CC Kevin, IIRC for bug#41077 he used a nice setup to
produce quite accurate results on memory footprint during the
compilation process.  Perhaps he has time and he's so kind to gather
some data on the current state, that would be extremely helpful.

>> As a note: in all cases except bootstrap the final pass (the one driving
>> libgccjit) is executed as a sub-process, this to protect us from
>> eventual GCC leaks and not to generate unnecessary fragmentation.  In
>> async compilation we indeed run all the compilation (also the Lisp
>> computation) in the child process, so compiling should not have impact
>> on the memory footprint of the main Emacs session.
>
> That's fine, but the memory footprint of such a subprocess is also of
> interest, as it could be relevant to the overall memory pressure of
> the OS, and thus indirectly on the parent Emacs process as well.

Indeed, I thought was relevant to make you aware of this mechanism.

>> > (Do we allow multiple async compilations, btw? if so, how many
>> > concurrent compilations can be running, and how do we or the user
>> > control that?)
>> 
>> Yes see <http://akrl.sdf.org/gccemacs.html#org91858b2>
>
> Thanks.  This needs further tuning, IMO, both per the FIXME
> (i.e. provide a primitive to return the number of execution units),
> and wrt the default value being half of the available units.  We
> should pay attention to the system's load average as well, I think.

Agree, I guess we'll be able to tune it better when we'll have more
data.  We could even think of using the memory pressure on the system to
make such a decision.

>> > Also, what are the numbers for a session that has been running for
>> > several days?  I understand that it would be hard for you to collect
>> > such numbers about all the configurations, but could you show the
>> > growth of the configuration you are routinely using, which I presume
>> > is --with-x --with-nativecomp and with your config?  As your numbers
>> > above show, it starts at 1.5 GiB, but what is the footprint after a
>> > day or a week?
>> 
>> ATM I can provide this number, this is an Aarch64 daemon compiled with
>> '--without-x' with an up-time of 25 days and is showing a footprint of
>> 765M.
>
> OK, thanks.
>
>> The hard part is to have a reference to compare against as the memory
>> footprint is strictly connected to the usage.  One with very regular
>> working habits should work like one week on vanilla and one week on
>> native-comp to make a comparison.  I've no regular working habits so I
>> fear I'm not the best fit for this comparison.
>
> I agree, these numbers still need to be collected.  Maybe we should
> ask on emacs-devel that people who use the branch report their
> numbers?

Is a good idea, my fear would be only to have very noisy or hard to
interpret results.  A priori I think would be nice to collect such data
also for master too.

Thanks

  Andrea




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#45705; Package emacs. (Sat, 09 Jan 2021 17:27:01 GMT) Full text and rfc822 format available.

Message #41 received at 45705 <at> debbugs.gnu.org (full text, mbox):

From: Kévin Le Gouguec <kevin.legouguec <at> gmail.com>
To: Andrea Corallo <akrl <at> sdf.org>
Cc: Eli Zaretskii <eliz <at> gnu.org>, edouard.debry <at> gmail.com,
 45705 <at> debbugs.gnu.org
Subject: Re: bug#45705: [feature/native-comp] Excessive memory consumption
 on windows 10
Date: Sat, 09 Jan 2021 18:26:46 +0100
[Message part 1 (text/plain, inline)]
Andrea Corallo <akrl <at> sdf.org> writes:

> Eli Zaretskii <eliz <at> gnu.org> writes:
>
>>> From: Andrea Corallo <akrl <at> sdf.org>
>>> 
>>> In June we changed the way we store immediate objects in the shared and
>>> this makes the compilation way lighter on the GCC side (both in time and
>>> memory).  I've no precise data on this other than the experimental
>>> observation that compiling all Elisp files in Emacs on 32bit systems is
>>> not anymore an issue.  This IIUC implies that the memory footprint for
>>> each compilation is always < 2GB.
>>
>> You assume that the compilations are all done serially?  AFAIK, most
>> people build Emacs with "make -jN", so parallel compilation is an
>> important use case.
>
>> I guess we will have to collect the information about that, if you say
>> we don't have it now.
>
> I'm adding in CC Kevin, IIRC for bug#41077 he used a nice setup to
> produce quite accurate results on memory footprint during the
> compilation process.  Perhaps he has time and he's so kind to gather
> some data on the current state, that would be extremely helpful.

See also bug#41194#20 and bug#41194#28 where I outlined how the
improvements reduced compilation time and memory usage.

I've dusted off my 32-bit laptop; unfortunately the fan sounds like it's
in need of… something (probably exorcism, given the noise).

Until I figure that out, here are the (very hacky) scripts I used to
measure and plot the RAM usage, in case someone else wants to take some
measurements:

- ./monitor.sh $PID finds the most RAM-consuming process among $PID and
  its children, and logs its memory usage (VSZ and RSS) and its
  command-line.

  (Logs are collected every 10 seconds; this probably needs to be
  reduced for faster machines)

- ./plot.py uses matplotlib to make graphs out of these measurements; it
  attempts to replace the command line with the less-verbose diagnostics
  from "make".

- My workflow was to start an emacs session, run M-x compile RET make,
  then ./monitor.sh $PID_OF_EMACS_SESSION.

  (PARENT_RE in plot.py should match the command-line of this parent
   session; its RAM consumption is then labeled as "noise floor" on the
   graph.

   This serves no real purpose and should be removed; monitor.sh should
   be amended to filter the parent session out of monitored PIDs, with
   some error control to handle the lack of child processes when
   compilation is finished.)

- There are some hardcoded things to tweak at the bottom of plot.py,
  e.g. how long should a child process last for it to have a label on
  the graph.

[monitor.sh (application/x-shellscript, attachment)]
[plot.py (text/x-python, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#45705; Package emacs. (Sat, 09 Jan 2021 19:42:02 GMT) Full text and rfc822 format available.

Message #44 received at 45705 <at> debbugs.gnu.org (full text, mbox):

From: Andrea Corallo <akrl <at> sdf.org>
To: Kévin Le Gouguec <kevin.legouguec <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, edouard.debry <at> gmail.com,
 45705 <at> debbugs.gnu.org
Subject: Re: bug#45705: [feature/native-comp] Excessive memory consumption
 on windows 10
Date: Sat, 09 Jan 2021 19:41:09 +0000
Kévin Le Gouguec <kevin.legouguec <at> gmail.com> writes:

> Andrea Corallo <akrl <at> sdf.org> writes:
>
>> Eli Zaretskii <eliz <at> gnu.org> writes:
>>
>>>> From: Andrea Corallo <akrl <at> sdf.org>
>>>> 
>>>> In June we changed the way we store immediate objects in the shared and
>>>> this makes the compilation way lighter on the GCC side (both in time and
>>>> memory).  I've no precise data on this other than the experimental
>>>> observation that compiling all Elisp files in Emacs on 32bit systems is
>>>> not anymore an issue.  This IIUC implies that the memory footprint for
>>>> each compilation is always < 2GB.
>>>
>>> You assume that the compilations are all done serially?  AFAIK, most
>>> people build Emacs with "make -jN", so parallel compilation is an
>>> important use case.
>>
>>> I guess we will have to collect the information about that, if you say
>>> we don't have it now.
>>
>> I'm adding in CC Kevin, IIRC for bug#41077 he used a nice setup to
>> produce quite accurate results on memory footprint during the
>> compilation process.  Perhaps he has time and he's so kind to gather
>> some data on the current state, that would be extremely helpful.
>
> See also bug#41194#20 and bug#41194#28 where I outlined how the
> improvements reduced compilation time and memory usage.
>
> I've dusted off my 32-bit laptop; unfortunately the fan sounds like it's
> in need of… something (probably exorcism, given the noise).

At the moment I think we are interested more in the magnitude order and
also a measure on 64bit would be very interesting.

But you are right I see in bug#41194#20 bug#41194#28 you've already
measured the footprint with the new immediate handling!

IIRC the worstcase was org.el under 600MB.  I think till we get a more
recent measure we should assume this as number (I don't expect huge
changes tho).

Many thanks

  Andrea




Merged 45705 45751. Request was from Andrea Corallo <akrl <at> sdf.org> to control <at> debbugs.gnu.org. (Tue, 12 Jan 2021 11:00:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 25 Feb 2021 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 54 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.