emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Indentation and gc


From: Ihor Radchenko
Subject: Re: Indentation and gc
Date: Sat, 11 Mar 2023 13:31:04 +0000

Eli Zaretskii <eliz@gnu.org> writes:

>> With the main risk being that we could go OOM, could Emacs evaluate the
>> available memory on the system on systems that support that check?
>
> It can, but what would you want to do with that value?
>
> We cannot use it as the threshold, for the reasons I explained
> earlier.  We could use some fraction of it, but what fraction?  The
> answer depends on what other programs routinely run on that system.
> For example, if the user is likely to run another full-fledged session
> of Emacs (some people actually do that, e.g., to run Gnus in a
> separate process), then using 1/2 of the amount of VM as the threshold
> is out of the question, right?  And there are memory-hogging programs
> out there which use much more than Emacs does.

What is the smallest practical free RAM available to Emacs on low-end systems?
We can take that value and then use 800kb/min free RAM in the wild and
the base threshold. On system with larger RAM the threshold will scale.

As a speculation, let's assume that the minimal sane memory we can
encounter is 128Mb. Then, 800kb correspond to ~0.7% RAM.

For systems with a lot of RAM, Say 128Gb, 0.7% corresponds to 890Mb.
Probably a bit much and will cause memory fragmentation

What about the default being:

(pcase (* (car (memory-info)) ; in kb
          1000)
  (`nil 800000) ; 800kb, old default
  (ram
   (let ((scaled-threshold
          (* 0.7e-2 ; 800kb/128Mb for low-end systems.
             ram)))
     (min
      (* 100 1000 1000) ; upper limit to avoid fragmentation
      scaled-threshold))))

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]