From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Spencer Baugh Newsgroups: gmane.emacs.devel Subject: [PATCH 1/3] Add gc-estimated-time variable Date: Tue, 17 Nov 2020 19:20:48 -0500 Message-ID: <20201118002050.16426-2-sbaugh@catern.com> References: <20201118002050.16426-1-sbaugh@catern.com> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16949"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Spencer Baugh To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Nov 18 01:22:35 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kfBF4-0004Lf-VK for ged-emacs-devel@m.gmane-mx.org; Wed, 18 Nov 2020 01:22:34 +0100 Original-Received: from localhost ([::1]:43184 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kfBF0-0001Ut-AQ for ged-emacs-devel@m.gmane-mx.org; Tue, 17 Nov 2020 19:22:32 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49246) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kfBDV-0000G7-Ch for emacs-devel@gnu.org; Tue, 17 Nov 2020 19:20:57 -0500 Original-Received: from venus.catern.com ([68.183.49.163]:50974) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kfBDS-0002aU-Fw for emacs-devel@gnu.org; Tue, 17 Nov 2020 19:20:57 -0500 Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235; helo=localhost; envelope-from=sbaugh@catern.com; receiver= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail; t=1605658853; bh=yGp/4ik8tQYKNBUrtENln501MYxGRh3YSrZVLul60tQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=cm2suUDjDR8P+mcVz1FL2t8U3yBqFejg7/znFpJZyzfI3f+NCGMBIHTasX/aEX8LW wquPRb1RikIy1uEurblDGLv9yw647N8ps3x3toUzf7z25d2PfM0ABuIGMViwy+umAj WMpGFWP36WOr3D1Uatuwgj9Il+i1Bnja6y45U+uE= Original-Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235]) by venus.catern.com (Postfix) with ESMTPSA id 6B9712DD834; Wed, 18 Nov 2020 00:20:53 +0000 (UTC) X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201118002050.16426-1-sbaugh@catern.com> Received-SPF: pass client-ip=68.183.49.163; envelope-from=sbaugh@catern.com; helo=venus.catern.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/17 19:20:53 X-ACL-Warn: Detected OS = Linux 3.11 and newer X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:259323 Archived-At: --- src/alloc.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/alloc.c b/src/alloc.c index 2b3643e35b..8d31903089 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