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 v2 00/16] Speeding up DEFVAR_PER_BUFFER Date: Sat, 21 Nov 2020 21:34:29 -0500 Message-ID: References: <20201119153814.17541-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="24368"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Spencer Baugh , Arnold Noronha , Stefan Monnier , Dmitry Gutov To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Nov 22 03:38:36 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 1kgfGu-0006Ep-DH for ged-emacs-devel@m.gmane-mx.org; Sun, 22 Nov 2020 03:38:36 +0100 Original-Received: from localhost ([::1]:50394 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kgfGt-0005NH-E2 for ged-emacs-devel@m.gmane-mx.org; Sat, 21 Nov 2020 21:38:35 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40888) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kgfDI-0000In-At for emacs-devel@gnu.org; Sat, 21 Nov 2020 21:34:52 -0500 Original-Received: from venus.catern.com ([68.183.49.163]:60096) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kgfDG-0007IU-F8 for emacs-devel@gnu.org; Sat, 21 Nov 2020 21:34:52 -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=1606012489; bh=MwKG9XBi4pAoo7aUx22fAnr9RltBMZAH62EtuV1FY5s=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=A7WTdyPTNrTDBkwbSgASHCnIzwRcb3J+Fn9/uOuV6ldNknKbd4CVjR29IBf/vPM6z mcBeIxdYoaHqedoiEg1UMLCPHFEsTEuu/4c0iOUhTwHWcmtFJNHurxQwHlEPaKZF60 LFHYfOSBsx/DpZR6wVCLtVJhvwTVIFjVWKtx1+VU= 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 56CA72DDA07; Sun, 22 Nov 2020 02:34:49 +0000 (UTC) X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201119153814.17541-1-sbaugh@catern.com> 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: 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:259578 Archived-At: This patch series reworks access to Lisp_Object fields in struct buffer. The primary motivation is performance of DEFVAR_PER_BUFFER Lisp variables, but this also removes several now-unnecessary pieces of metadata and generally simplifies things. Relative to v1, this patch series now performs a larger refactoring of struct buffer field access, which should provide for good performance while keeping the access method uniform. I've also corrected style issues and bugs pointed out in review, and added some testing for buffer-local let variables. (Thanks Stefan for the review, and the tests you added in the fix for bug#44733, both were quite helpful.) It's possible to provide further performance improvements, although the current state of the patch series has minimal overhead, and the uniformity is somewhat appealing. If we do need to completely remove the overhead, we could do a mass change to all the uses of BVAR, to introduce separate, maybe, BVAR_LISP and BVAR_C macros, for fields which need fallback and fields which don't. I wasn't sure whether that would be acceptable. I have an idea which would allow avoiding the mass change, if that's desired, which also has some additional benefits. We could define getter functions (marked as inline) for each Lisp_Object field, and have BVAR call those field-specific getter functions by forming the name of the getter through token pasting. The boilerplate of the getters would be kept under control by using an X macro to define both the fields in struct buffer and the getters. Something like: #define FIELD_LIST \ C_FIELD(name) \ C_FIELD(filename) \ ... LISP_FIELD(mode_line_format) \ ... And then "instantiating" FIELD_LIST twice in two different contexts to define the Lisp_Object fields and the getters. This would have some additional benefits: - it would make it a lot easier to tell which fields are C-only and which fields are accessed from Lisp - we can attach more metadata to the individual fields - we could also generate the existing hand-written setters from these macros Regardless of what approach we take, at least some level of benchmarking will be necessary. Is there an established benchmark suite for these kinds of changes? (My commit messages are still not in ChangeLog style - sorry - with 16 patches in the series right now, and having not yet personally figured out a good magit-integrated way to generate ChangeLog-appropriate messages, I figured I'm better off adjusting the commit messages at the end of the review process, rather than continually throughout. If anyone has a recommendation for ChangeLog generation that is integrated with magit, that would be welcome - I haven't found anything yet...) Spencer Baugh (16): Add a test for let-binding unwinding Assert not local-variable-p after setq in let_default binding Stop checking the constant default for enable_multibyte_characters Take buffer field name in DEFVAR_PER_BUFFER Add BVAR_DEFAULT for access to buffer defaults Use bset_* functions instead of BVAR Take offset not idx in PER_BUFFER_VALUE_P Combine unnecessarily separate loops in buffer.c Add and use BUFFER_DEFAULT_VALUE_P Add and use KILL_PER_BUFFER_VALUE Assert that PER_BUFFER_IDX for Lisp variables is not 0 Rearrange set_internal for buffer forwarded symbols Get rid of buffer_permanent_local_flags array Remove unnecessary Qunbound check Remove local_flags array in struct buffer Remove usage of buffer_local_flags lisp/bindings.el | 3 +- src/buffer.c | 417 ++++++++++++----------------------------- src/buffer.h | 145 ++++++-------- src/category.c | 4 - src/category.h | 2 +- src/data.c | 82 ++------ src/fileio.c | 12 +- src/pdumper.c | 3 - src/print.c | 6 +- src/process.c | 15 +- src/syntax.c | 4 - src/syntax.h | 2 +- src/window.c | 5 +- test/src/data-tests.el | 24 ++- 14 files changed, 228 insertions(+), 496 deletions(-) -- 2.28.0