emacs-devel
[Top][All Lists]
Advanced

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

Re: Larger GC thresholds for non-interactive Emacs


From: Ihor Radchenko
Subject: Re: Larger GC thresholds for non-interactive Emacs
Date: Sat, 18 Jun 2022 13:35:04 +0800

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> BTW, I seen everyone's focused on `gc-cons-threshold` but that variable
> does not adapt to the heap size, so maybe we'd be better off
> playing with `gc-cons-percentage`.

I am not sure if `gc-cons-percentage' is reliable.
When we have a small heap (at the beginning of the batch command run),
the GC will be triggered frequently. Later, after initial memory
allocations for data structures is complete, the same
`gc-cons-percentage' will make GC fire less frequently and will have
nothing to do with actually allocated/deallocated memory objects in the
subsequent parts of the batch process.

Consider the following example:

(defun init () (allocate-huge-hash-map-object))
(defun run () (dolist (...) (let (this and that) (query the huge hash-map))))
(init)
(run)

The (init) part will trigger frequent GCs yielding no of very small
amount of garbage being collected.

The (run) part may use more temporary allocations. Yet, GC will be
triggered much less frequently simply because the atomic (let ...)
allocations are small compared to the initially allocated hash-map
object.

I believe that gc-cons-threshold will still be useful as _an upper
bound_ to trigger GC. gc-cons-percentage is probably more efficient when
it triggers below gc-cons-threshold.

Best,
Ihor



reply via email to

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