diff options
| author | Paul Eggert | 2019-09-14 00:32:01 -0700 |
|---|---|---|
| committer | Paul Eggert | 2019-09-14 00:37:26 -0700 |
| commit | bac66302e92bdd3a353102d2076548e7e83d92e5 (patch) | |
| tree | 6007fc144e41b0a0f0eb43bf11100eb4ce8085d4 /src/lisp.h | |
| parent | e4fb98b542c57fa4856fbeb14230ace34d910117 (diff) | |
| download | emacs-bac66302e92bdd3a353102d2076548e7e83d92e5.tar.gz emacs-bac66302e92bdd3a353102d2076548e7e83d92e5.zip | |
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.
Diffstat (limited to 'src/lisp.h')
| -rw-r--r-- | src/lisp.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/lisp.h b/src/lisp.h index 024e5edb26e..02f8a7b6686 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -3824,9 +3824,10 @@ extern void mark_maybe_objects (Lisp_Object const *, ptrdiff_t); | |||
| 3824 | extern void mark_stack (char const *, char const *); | 3824 | extern void mark_stack (char const *, char const *); |
| 3825 | extern void flush_stack_call_func (void (*func) (void *arg), void *arg); | 3825 | extern void flush_stack_call_func (void (*func) (void *arg), void *arg); |
| 3826 | extern void garbage_collect (void); | 3826 | extern void garbage_collect (void); |
| 3827 | extern void maybe_garbage_collect (void); | ||
| 3827 | extern const char *pending_malloc_warning; | 3828 | extern const char *pending_malloc_warning; |
| 3828 | extern Lisp_Object zero_vector; | 3829 | extern Lisp_Object zero_vector; |
| 3829 | extern intmax_t consing_until_gc; | 3830 | extern EMACS_INT consing_until_gc; |
| 3830 | #ifdef HAVE_PDUMPER | 3831 | #ifdef HAVE_PDUMPER |
| 3831 | extern int number_finalizers_run; | 3832 | extern int number_finalizers_run; |
| 3832 | #endif | 3833 | #endif |
| @@ -5056,7 +5057,7 @@ INLINE void | |||
| 5056 | maybe_gc (void) | 5057 | maybe_gc (void) |
| 5057 | { | 5058 | { |
| 5058 | if (consing_until_gc < 0) | 5059 | if (consing_until_gc < 0) |
| 5059 | garbage_collect (); | 5060 | maybe_garbage_collect (); |
| 5060 | } | 5061 | } |
| 5061 | 5062 | ||
| 5062 | INLINE_HEADER_END | 5063 | INLINE_HEADER_END |