]> git.eshelyaron.com Git - emacs.git/commit
Improve gc-cons-percentage calculation
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 14 Sep 2019 07:32:01 +0000 (00:32 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 14 Sep 2019 07:37:26 +0000 (00:37 -0700)
commitbac66302e92bdd3a353102d2076548e7e83d92e5
tree6007fc144e41b0a0f0eb43bf11100eb4ce8085d4
parente4fb98b542c57fa4856fbeb14230ace34d910117
Improve gc-cons-percentage calculation

The old calculation relied on a hodgpodge of partly updated GC
stats to find a number to multiply gc-cons-percentage by.
The new one counts data found by the previous GC, plus half of
the data allocated since then; this is more systematic albeit
still ad hoc.
* src/alloc.c (consing_until_gc, gc_threshold, consing_threshold):
Now EMACS_INT, not intmax_t.
(HI_THRESHOLD): New macro.
(tally_consing): New function.
(make_interval, allocate_string, allocate_string_data)
(make_float, free_cons, allocate_vectorlike, Fmake_symbol): Use it.
(allow_garbage_collection, inhibit_garbage_collection)
(consing_threshold, garbage_collect):
Use HI_THRESHOLD rather than INTMAX_MAX.
(consing_threshold): New arg SINCE_GC.  All callers changed.
(bump_consing_until_gc): Return new consing_until_gc, instead of
nil.  All callers changed.  Don’t worry about overflow since we
now saturate at HI_THRESHOLD.  Guess that half of
recently-allocated objects are still alive, instead of relying on
the previous (even less-accurate) hodgepodge.
(maybe_garbage_collect): New function.
(garbage_collect): Work even if a finalizer disables or enables
memory profiling.  Do not use malloc_probe if GC reclaimed nothing.
* src/lisp.h (maybe_gc): Call maybe_garbage_collect instead
of garbage_collect.
src/alloc.c
src/lisp.h