[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 1/3] Add gc-estimated-time variable
From: |
Spencer Baugh |
Subject: |
[PATCH v2 1/3] Add gc-estimated-time variable |
Date: |
Sun, 22 Nov 2020 00:08:27 -0500 |
---
src/alloc.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/src/alloc.c b/src/alloc.c
index 2b3643e35b..fd572c0175 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -6129,10 +6129,19 @@ garbage_collect (void)
/* Accumulate statistics. */
if (FLOATP (Vgc_elapsed))
{
+ const struct timespec this_gc_elapsed =
+ timespec_sub (current_timespec (), start);
static struct timespec gc_elapsed;
- gc_elapsed = timespec_add (gc_elapsed,
- timespec_sub (current_timespec (), start));
+ gc_elapsed = timespec_add (gc_elapsed, this_gc_elapsed);
Vgc_elapsed = make_float (timespectod (gc_elapsed));
+ static double gc_time_ema;
+ if (gc_time_ema == 0.0)
+ /* Initialize exponential moving average to first GC time. */
+ gc_time_ema = timespectod (this_gc_elapsed);
+ else
+ /* Decay very fast, since heap size can change rapidly. */
+ gc_time_ema = 0.5 * gc_time_ema + 0.5 * timespectod (this_gc_elapsed);
+ Vgc_estimated_time = make_float (gc_time_ema);
}
gcs_done++;
@@ -7528,6 +7537,11 @@ do hash-consing of the objects allocated to pure space.
*/);
The time is in seconds as a floating point value. */);
DEFVAR_INT ("gcs-done", gcs_done,
doc: /* Accumulated number of garbage collections done. */);
+ DEFVAR_LISP ("gc-estimated-time", Vgc_estimated_time,
+ doc: /* An estimate of the time required for the next garbage
collection.
+The time is in seconds as a floating point value.
+This is calculated as an exponential moving average of the time
+required for previous garbage collections. */);
DEFVAR_INT ("integer-width", integer_width,
doc: /* Maximum number N of bits in safely-calculated integers.
--
2.28.0
- Re: Eager garbage collection, (continued)
- Re: Eager garbage collection, Spencer Baugh, 2020/11/18
- Re: Eager garbage collection, Andrea Corallo, 2020/11/18
- Re: Eager garbage collection, Stefan Monnier, 2020/11/18
- Re: Eager garbage collection, Andrea Corallo, 2020/11/18
- Re: Eager garbage collection, Eli Zaretskii, 2020/11/18
- Re: Eager garbage collection, Eli Zaretskii, 2020/11/18
- Re: Eager garbage collection, Spencer Baugh, 2020/11/22
- [PATCH v2 1/3] Add gc-estimated-time variable,
Spencer Baugh <=
- Re: [PATCH v2 1/3] Add gc-estimated-time variable, Eli Zaretskii, 2020/11/22
- Re: [PATCH v2 1/3] Add gc-estimated-time variable, Stefan Monnier, 2020/11/22
- [PATCH v2 2/3] Add garbage-collect-maybe function, Spencer Baugh, 2020/11/22
- Re: [PATCH v2 2/3] Add garbage-collect-maybe function, Eli Zaretskii, 2020/11/22
- [PATCH v2 3/3] Start opportunistic GC timer at startup, Spencer Baugh, 2020/11/22
- Re: Eager garbage collection, Eli Zaretskii, 2020/11/22
- Re: Eager garbage collection, yyoncho, 2020/11/18
- Re: Eager garbage collection, Eli Zaretskii, 2020/11/18
- Re: Eager garbage collection, Stefan Monnier, 2020/11/18
- Re: Eager garbage collection, Stefan Monnier, 2020/11/18