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: Re: Eager garbage collection Date: Wed, 18 Nov 2020 10:19:26 -0500 Message-ID: <87wnyik801.fsf@catern.com> References: <20201118002050.16426-1-sbaugh@catern.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18677"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Andrea Corallo Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Nov 18 16:20:11 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 1kfPFh-0004iU-8C for ged-emacs-devel@m.gmane-mx.org; Wed, 18 Nov 2020 16:20:09 +0100 Original-Received: from localhost ([::1]:44614 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kfPFg-0003Ne-Ak for ged-emacs-devel@m.gmane-mx.org; Wed, 18 Nov 2020 10:20:08 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34292) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kfPF4-0002wg-9b for emacs-devel@gnu.org; Wed, 18 Nov 2020 10:19:30 -0500 Original-Received: from venus.catern.com ([68.183.49.163]:52282) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kfPF1-0001eN-Tf for emacs-devel@gnu.org; Wed, 18 Nov 2020 10:19:29 -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=1605712766; bh=JzLBP+Vumi+g3OvQEypNnjVrtVqP06LiuILN5WXru8Y=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=gpcBQ70rpIAZ8f8aBQ6Cp2bc/1dEpWrWh3f+LCG5ppmi93HvtOSLMjLOZDPukFETl Jq/WNLOJDqxDv3iuBzQgFiPuXijD2JenQrTCGMx4aKY1nGDvIKU3mK0FH/klmRv6Wo dk7zkdybc7so9iRjJZLhA2NniVHdKGudq3VhzFyw= 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 42D202DD696; Wed, 18 Nov 2020 15:19:26 +0000 (UTC) In-Reply-To: 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/18 10:19:27 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:259352 Archived-At: Andrea Corallo writes: > My question is, what is the advantage of this implementation respect the > pure Lisp one we have? > > > > AFAIU they achieve the same. If that's the case I indeed prefer the > Lisp one as simpler and easier to extend. The core necessary thing that requires C changes is making a garbage collection function which "maybe" does a garbage collect. gcmh.el always does a full garbage collection when idle, even if there's no garbage. That will hurt responsiveness, especially with a very large heap (as gcmh configures), because GC takes time proportional to the size of the heap, not the amount of garbage. Possibly, we could rely on the fact that maybe_gc gets called automatically as part of Lisp evaluation. Then we'd just want to ensure that GC happens eagerly, which we could do by lowering gc-cons-threshold while idle. But that's excessively magical, I would say. Although, I suppose we could just expose consing_until_gc, or some other variable, to Lisp. Then the eager maybe-GC logic could be in Lisp: Recalculate a local consing_until_gc and decide whether or not to call garbage-collect based on that, just like the C code does. It would duplicate some logic between Lisp and C, but maybe that's ok. If others think that's a good idea, I can change to just exposing consing_until_gc.