unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Ihor Radchenko <yantar92@posteo.net>
Cc: arne_bab@web.de, spacibba@aol.com, emacs-devel@gnu.org
Subject: Re: Indentation and gc
Date: Sat, 11 Mar 2023 15:38:09 +0200	[thread overview]
Message-ID: <83edpvwgqm.fsf@gnu.org> (raw)
In-Reply-To: <87edpvwi0k.fsf@localhost> (message from Ihor Radchenko on Sat, 11 Mar 2023 13:10:35 +0000)

> From: Ihor Radchenko <yantar92@posteo.net>
> Cc: arne_bab@web.de, spacibba@aol.com, emacs-devel@gnu.org
> Date: Sat, 11 Mar 2023 13:10:35 +0000
> 
> If so, as you said, there is no guarantee that the threshold is never
> exceeded. So, running Emacs when the available memory is extremely close
> to the heap size is not safe anyway.

What do you mean  by "heap size" here?

We aren't talking about the heap, we are talking about the VM size of
the system, vs how much of that is typically consumed by programs.
The answer depends on the system and on the usage patterns.

> Emacs may start exceeding memory limits just from loading an extra
> package of something along that lines.

It depends how large is the memory consumption of that package and how
much memory the system has.

> Memory-constrained users probably need to carefully search for a balance
> anyway.

The current GC threshold is unlikely to cause problems on systems with
even very little memory.  Emacs itself needs around 15 to 20 MiB even
when started with -Q, so if the system is capable of running Emacs, it
should be able to cope with relatively minor increases of the memory
footprint, such as what the default GC threshold produces.

You suggest increasing the threshold significantly, which could make
the danger of OOM much higher, especially on memory-challenged
systems.

> What about setting gc-cons-threshold (and leaving gc-cons-percentage
> intact) as a fraction of the available memory as returned by
> `memory-info'?

See my other message a few minutes ago, where I already responded to a
similar proposal.

> At least, when loading init.el. This can be a custom
> setting like `gc-cons-threshold-init' that may either be nil (fall back
> to `gc-cons-threshold'), an integer (bytes), or a float representing a
> fraction of free memory. The default can be a fraction of free memory,
> if memory info is available for a given system.

Which fraction?

If we leave determination of the fraction to the user, we might as
well not provide any new defcustoms at all, since the existing
variables cover that, and you are saying that everyone increases the
threshold to most-positive-fixnum anyway.

> I'd introduce a custom setting `gc-cons-percentage-2/`gc-cons-threshold-2'
> that will define an alternative (larger) GC threshold that is used for a
> command if the number of GCs exceeds `gcs-done-threshold'.

How is this different from what we already have?

> Upon finishing the command, GC thresholds are lowered back to standard.

Why only "command"?  What about stuff that runs from post-command-hook
or from timers or from process filters?  Some of them could be as
performance critical as an interactive command, no?

> >   . how to determine the ceiling for increasing the threshold?
> 
> That's a good question.

That's the main question, from my POV.  Without a good answer, we
don't have any reason to introduce any new features related to this.

> I'd start with trying 5-10x normal value of gc-cons-percentage for
> commands that spend more than 0.1-0.2 sec (noticeable delay) in more
> than a single GC.

Again: why only commands?

And how to know which ones will take more that the times you consider
as significant?  (And why should everyone use these times, which
appear to be quite low?)

> Then, I'd add some code that will collect statistics of the impact
> of the new setting. After some time, I will ask users to share the
> statistics in one of the Emacs surveys or just by asking on mailing
> list.

Then we should start with just this, and revisit the issue only after
we have some significant statistics.  Note that users will have to
tell much more than just threshold numbers: they will need to tell how
much memory they have and also the memory footprints of the programs
running on their systems.



  reply	other threads:[~2023-03-11 13:38 UTC|newest]

Thread overview: 99+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20230310110747.4hytasakomvdyf7i.ref@Ergus>
2023-03-10 11:07 ` Indentation and gc Ergus
2023-03-10 14:36   ` Dr. Arne Babenhauserheide
2023-03-10 14:54     ` Eli Zaretskii
2023-03-10 19:23       ` Dr. Arne Babenhauserheide
2023-03-11  6:38         ` Eli Zaretskii
2023-03-11  6:55           ` Dr. Arne Babenhauserheide
2023-03-11  7:56             ` Eli Zaretskii
2023-03-11 12:34               ` Dr. Arne Babenhauserheide
2023-03-11 13:08                 ` Eli Zaretskii
2023-03-11 13:31                   ` Ihor Radchenko
2023-03-11 13:44                     ` Eli Zaretskii
2023-03-11 13:53                       ` Ihor Radchenko
2023-03-11 14:09                         ` Eli Zaretskii
2023-03-12 14:20                           ` Ihor Radchenko
2023-03-12 14:40                             ` Eli Zaretskii
2023-03-12 15:04                               ` Ihor Radchenko
2023-03-12 15:26                                 ` Eli Zaretskii
2023-03-13 15:09                                   ` Ihor Radchenko
2023-03-13 15:37                                     ` Eli Zaretskii
2023-03-13 15:45                                       ` Ihor Radchenko
2023-03-13 16:58                                         ` Eli Zaretskii
2023-03-13 18:04                                           ` Ihor Radchenko
2023-03-14 12:19                                             ` Eli Zaretskii
2023-03-15 10:28                                               ` Ihor Radchenko
2023-03-15 12:54                                                 ` Eli Zaretskii
2023-03-15 12:59                                                   ` Ihor Radchenko
2023-03-15 14:20                                                     ` Eli Zaretskii
2023-03-16 10:27                                                       ` Ihor Radchenko
2023-04-06  9:13                                                         ` Ihor Radchenko
2023-04-08  8:04                                                           ` Eli Zaretskii
2023-04-08  8:15                                                             ` Ihor Radchenko
2023-04-08 10:03                                                               ` Eli Zaretskii
2023-04-14 17:07                                                                 ` Ihor Radchenko
2023-04-14 17:56                                                                   ` Eli Zaretskii
2023-03-13 18:14                                         ` Gregor Zattler
2023-03-14 12:30                                           ` Eli Zaretskii
2023-03-14 15:19                                             ` Gregor Zattler
2023-03-11 16:19                     ` Dr. Arne Babenhauserheide
2023-03-12 13:27                       ` Ihor Radchenko
2023-03-12 14:10                         ` Eli Zaretskii
2023-03-12 14:50                           ` Ihor Radchenko
2023-03-12 15:13                             ` Eli Zaretskii
2023-03-12 17:15                               ` Gregor Zattler
2023-03-12 20:07                                 ` Eli Zaretskii
2023-03-13 15:01                               ` Ihor Radchenko
2023-03-13 15:33                                 ` Eli Zaretskii
2023-03-13 15:39                                   ` Ihor Radchenko
2023-03-13 15:39                                     ` Eli Zaretskii
2023-03-13 16:04                                       ` Ihor Radchenko
2023-03-13 16:52                                         ` Eli Zaretskii
2023-03-14 12:47                                           ` Ihor Radchenko
2023-03-14 13:09                                             ` Eli Zaretskii
2023-03-15 10:29                                               ` Ihor Radchenko
2023-03-13 15:41                                 ` Eli Zaretskii
2023-03-14 13:01                                   ` Ihor Radchenko
2023-03-11 10:54       ` Ihor Radchenko
2023-03-11 11:17         ` Ergus
2023-03-11 11:23           ` Ihor Radchenko
2023-03-11 12:31           ` Eli Zaretskii
2023-03-11 12:39             ` Ihor Radchenko
2023-03-11 12:40               ` Eli Zaretskii
2023-03-11 12:54                 ` Ihor Radchenko
2023-03-11 13:01                   ` Dr. Arne Babenhauserheide
2023-03-11 13:14                   ` Eli Zaretskii
2023-03-11 13:38                     ` Ihor Radchenko
2023-03-11 13:46                       ` Eli Zaretskii
2023-03-11 13:54                         ` Ihor Radchenko
2023-03-11 14:11                           ` Eli Zaretskii
2023-03-11 14:18                             ` Ihor Radchenko
2023-03-11 14:20                               ` Eli Zaretskii
2023-03-11 14:31                                 ` Ihor Radchenko
2023-03-11 15:32                                   ` Eli Zaretskii
2023-03-11 15:52                                     ` Lynn Winebarger
2023-03-11 16:24                                       ` Eli Zaretskii
2023-03-11 17:10                                     ` Gregor Zattler
2023-03-11 17:25                                       ` Eli Zaretskii
2023-03-11 18:35                                         ` Gregor Zattler
2023-03-11 18:49                                           ` Eli Zaretskii
2023-03-13 12:45                                     ` Ihor Radchenko
2023-03-13 12:51                                       ` Eli Zaretskii
2023-06-14 14:16                                         ` Ihor Radchenko
2023-06-14 15:36                                           ` Eli Zaretskii
2023-06-14 15:58                                             ` Ihor Radchenko
2023-06-14 16:07                                               ` Eli Zaretskii
2023-06-16 10:00                                                 ` Ihor Radchenko
2023-06-16 10:33                                                   ` Eli Zaretskii
2023-06-16 11:03                                                     ` Ihor Radchenko
2023-06-16 11:34                                                       ` Eli Zaretskii
2023-06-21 10:37                                                         ` Ihor Radchenko
2023-06-21 11:11                                                           ` Eli Zaretskii
2023-03-11 13:00                 ` Po Lu
2023-03-11 12:37         ` Eli Zaretskii
2023-03-11 13:10           ` Ihor Radchenko
2023-03-11 13:38             ` Eli Zaretskii [this message]
2023-03-10 14:52   ` Eli Zaretskii
2023-03-10 21:30     ` Ergus
2023-03-11  6:52       ` Eli Zaretskii
2023-03-21  7:11   ` Jean Louis
2023-03-21  7:27     ` Emanuel Berg

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=83edpvwgqm.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=arne_bab@web.de \
    --cc=emacs-devel@gnu.org \
    --cc=spacibba@aol.com \
    --cc=yantar92@posteo.net \
    /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).