unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Dmitrii Korobeinikov <dim1212k@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel <emacs-devel@gnu.org>
Subject: Re: Garbage collector: is 800kb a good default?
Date: Thu, 9 Apr 2020 20:20:20 +0600	[thread overview]
Message-ID: <CA+Yh0SSjLGDRNscdJM64Q=u4ZgNenzZSWYMVnhZojp+xpP_PYw@mail.gmail.com> (raw)
In-Reply-To: <jwvh7xs4wtt.fsf-monnier+emacs@gnu.org>

> Running GC frequently is done largely to try and keep total heap size
> and memory fragmentation under control.  So completely refraining from
> running GC while non-idle is probably not a great solution, but I do
> agree that adding a "GC when idle" would not only be great in itself but
> would also let us increase the default thresholds somewhat.  Tho I don't
> think we can increase the threshold as much as you suggest without
> having significant detrimental effects.

So, are there any stats on how much worse the fragmentation gets w/
higher thresholds and how much it effects emacs as a result? (By the
way, I am not really suggesting 80MB, just testing it out at the
moment : ) )

> 2- 38% is pretty high

Just for the reference, I've seen the value of 25 in one of the
threads nearby [1], not sure why mine is so high.

Best,
DK

[1] https://lists.gnu.org/archive/html/emacs-devel/2020-04/msg00406.html

чт, 9 апр. 2020 г. в 19:47, Stefan Monnier <monnier@iro.umontreal.ca>:
>
> > Of course, raising the threshold significantly higher on its own is
> > not a very good idea. But if paired with an idle timer like suggested
> > here [2], then it all starts looking like a decent combination:
>
> I agree that it's worth investigating improvements based on dynamically
> changing the GC threshold.  What you're pointing out is that from the
> user's point of view, a GC during idle time is free (so it can occur
> frequently) and also that a GC during non-idle time can delay redisplay,
> so (ignoring all other impacts of GC) we should refrain from running GC
> while non-idle and trigger GC everything we're idle.
>
> Running GC frequently is done largely to try and keep total heap size
> and memory fragmentation under control.  So completely refraining from
> running GC while non-idle is probably not a great solution, but I do
> agree that adding a "GC when idle" would not only be great in itself but
> would also let us increase the default thresholds somewhat.  Tho I don't
> think we can increase the threshold as much as you suggest without
> having significant detrimental effects.
>
> There 2 additional ways to attack the problem, BTW:
>
> 1- replace our GC with a concurrent GC.  This would let us move those
>    38% GC overheard to one of the other CPU cores sitting idle while the
>    only CPU core running Emacs is frantically trying to scroll through
>    your buffer (it would also slow down both the GC and the main thread
>    a bit, but in the current context of plentiful CPU cores it would
>    still be very worthwhile).
>    [ Along the same lines, making our GC parallel could cut those 38%
>      down to some extent, as would a generational GC.  ]
>
> 2- 38% is pretty high.  Usually this indicates that the GC is not
>    efficient: it works hard yet reclaims very little memory likely
>    because the application is allocating a lot of objects which are
>    *not* temporary.  This is also the typical situation during Emacs's
>    startup where we're loading packages and initializing big
>    data-structures, so after allocating our GC-threshold of data the GC
>    is run but doesn't collect much garbage because all that data is
>    there to stay.
>    We can't really know beforehand if a GC will reclaim a lot of memory,
>    but we could "use the past to predict the future": we could set the
>    threshold higher when the last GC reclaimed too little garbage.
>
> I had sent a tentative patch for the "GC when idle" feature but it had
> some rough edges, and some details of the GC code have changed since.
> I'd welcome a patch to do that.  It shouldn't require many changes.
> Similarly, point (2) above should be fairly simple to add.
>
>
>         Stefan
>



  reply	other threads:[~2020-04-09 14:20 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-09 11:59 Garbage collector: is 800kb a good default? Dmitrii Korobeinikov
2020-04-09 12:33 ` Eli Zaretskii
2020-04-09 13:44   ` Dmitrii Korobeinikov
2020-04-09 14:02     ` Eli Zaretskii
2020-04-09 14:46       ` Dmitrii Korobeinikov
2020-04-09 16:42         ` Eli Zaretskii
2020-04-10 16:40           ` Dmitrii Korobeinikov
2020-04-09 19:05         ` Stefan Monnier
2020-04-10 16:26           ` Dmitrii Korobeinikov
2020-04-09 18:48     ` Stefan Monnier
2020-04-10 14:26   ` Bruno Félix Rezende Ribeiro
2020-04-10 16:49     ` Eli Zaretskii
2020-04-10 18:26       ` Bruno Félix Rezende Ribeiro
2020-04-10 18:53         ` Paul Eggert
2020-04-09 13:47 ` Stefan Monnier
2020-04-09 14:20   ` Dmitrii Korobeinikov [this message]
2020-04-09 14:23   ` Eli Zaretskii
2020-04-09 18:42     ` Stefan Monnier
2020-04-09 19:08       ` Eli Zaretskii
2020-04-09 19:31         ` Stefan Monnier
2020-04-10  6:19           ` Eli Zaretskii
2020-04-10 13:03             ` Stefan Monnier
2020-04-10 13:42               ` Eli Zaretskii
2020-04-10 14:34                 ` Stefan Monnier
2020-04-10 14:38                   ` Stefan Monnier
2020-04-10 15:37                   ` Eli Zaretskii
2020-04-10 15:52                   ` Andrea Corallo
2020-04-10 16:45                     ` Stefan Monnier
2020-04-10 17:18                       ` Andrea Corallo
2020-04-09 14:48   ` Andrea Corallo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CA+Yh0SSjLGDRNscdJM64Q=u4ZgNenzZSWYMVnhZojp+xpP_PYw@mail.gmail.com' \
    --to=dim1212k@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).