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.bugs Subject: bug#48264: 28.0.50; Changing the default for DEFVAR_PER_BUFFER variables takes O(#buffers) time Date: Thu, 06 May 2021 16:24:30 -0400 Message-ID: <877dkbsj9d.fsf@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="19223"; mail-complaints-to="usenet@ciao.gmane.io" To: 48264@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu May 06 22:25:36 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1lekYy-0004wJ-2x for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 06 May 2021 22:25:36 +0200 Original-Received: from localhost ([::1]:33158 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lekYx-0005V5-2w for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 06 May 2021 16:25:35 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57612) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lekYQ-0005TA-Dy for bug-gnu-emacs@gnu.org; Thu, 06 May 2021 16:25:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:56175) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lekYQ-0003VS-4w for bug-gnu-emacs@gnu.org; Thu, 06 May 2021 16:25:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lekYP-0007ei-Uw for bug-gnu-emacs@gnu.org; Thu, 06 May 2021 16:25:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 06 May 2021 20:25:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 48264 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.162033268029396 (code B ref -1); Thu, 06 May 2021 20:25:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 6 May 2021 20:24:40 +0000 Original-Received: from localhost ([127.0.0.1]:39483 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lekY4-0007e4-83 for submit@debbugs.gnu.org; Thu, 06 May 2021 16:24:40 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:34010) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lekY0-0007dw-Qa for submit@debbugs.gnu.org; Thu, 06 May 2021 16:24:38 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57528) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lekY0-00057T-E3 for bug-gnu-emacs@gnu.org; Thu, 06 May 2021 16:24:36 -0400 Original-Received: from venus.catern.com ([68.183.49.163]:44274) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lekXy-0003Cj-Qn for bug-gnu-emacs@gnu.org; Thu, 06 May 2021 16:24:36 -0400 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=1620332673; bh=3fAEMzbzxSwFkt3W89kKSkiLPUZ/+wnzYXok8jv3bXg=; h=From:To:Subject:Date; b=Rcp5RKs5qMKx9Fe5/gL3g19FOeWfkzHXcS0hRACc3SrvhjAd2uThp+SXcaUbP3UuM qHkMIS5dYuLtAgXm5Y+VqiXzSUGlWmZyz/VoZh9I3CtGK1r6jihaHBQPWaz1iA082g DqlUAsfWS/9GWCHptmj/Ro6WlYrU8RnN56TQtoAI= 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 8575E2E907E for ; Thu, 6 May 2021 20:24:31 +0000 (UTC) Received-SPF: pass client-ip=68.183.49.163; envelope-from=sbaugh@catern.com; helo=venus.catern.com 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: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:205878 Archived-At: When changing the default for a Lisp variable defined in the C source with the DEFVAR_PER_BUFFER macro, whether by let or by set-default, it takes time proportional to the number of currently live buffers. Note, DEFVAR_PER_BUFFER variables are stored as Lisp_Object fields in struct buffer. The cause of the pathological performance is that setting a default for a DEFVAR_PER_BUFFER variable iterates over every struct buffer (that doesn't already have a binding) to set the field corresponding to the variable. This is because accessing a DEFVAR_PER_BUFFER variable is done purely by looking at the current buffer, even if the buffer doesn't have a local binding for the variable. This issue was previously reported in bug#41029 and noticed as part of several other bugs. I have a patch series which fixes this issue by making DEFVAR_PER_BUFFER variable accesses fall back to the default if there's no local binding for the variable, which I'll send shortly as a followup.