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: [PATCH v2 00/16] Speeding up DEFVAR_PER_BUFFER Date: Sun, 22 Nov 2020 11:28:27 -0500 Message-ID: <87a6v9jqz8.fsf@catern.com> References: <20201119153814.17541-1-sbaugh@catern.com> <837dqdxtea.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21363"; mail-complaints-to="usenet@ciao.gmane.io" Cc: arnold@tdrhq.com, dgutov@yandex.ru, monnier@iro.umontreal.ca, Richard Stallman , emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Nov 22 17:29:10 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 1kgsEg-0005OG-Hn for ged-emacs-devel@m.gmane-mx.org; Sun, 22 Nov 2020 17:29:10 +0100 Original-Received: from localhost ([::1]:36646 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kgsEf-0002tA-Gx for ged-emacs-devel@m.gmane-mx.org; Sun, 22 Nov 2020 11:29:09 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35376) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kgsE5-0002TW-L8 for emacs-devel@gnu.org; Sun, 22 Nov 2020 11:28:33 -0500 Original-Received: from venus.catern.com ([68.183.49.163]:33100) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kgsE3-0005QI-PM; Sun, 22 Nov 2020 11:28:33 -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=1606062507; bh=FuFr8S1a5g6Awa942NQkQvDrZTcwNtTuNwNi8YlEAq0=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=GZa2NTIm958QYbdAGZ3sPs4o4ICuYHPuYdwMkIxTH+Pwys6KDVfDJzSzotLqWok45 X9+Xz/KkmGxOPxYw3k/MhH7+zL3puycJ+PtAE5Sk5QzaAchj1awmqt4TQSB5eQ22WJ emA/OX9/AxVN5laWoRlpnR46f+/IlsJrTHEf28eo= 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 6D3B92DDDF7; Sun, 22 Nov 2020 16:28:27 +0000 (UTC) In-Reply-To: <837dqdxtea.fsf@gnu.org> 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:259623 Archived-At: Eli Zaretskii writes: > Thanks, but could you perhaps provide a more detailed overview of the > general idea of the changeset? It is not easy to glean that from 16 > patches, each one describing only the details of its narrow goal. > Please include in the more detailed overview indications what parts of > the series are really needed to speed up buffer-local variables and > which are cleanups in the areas of the changes not directly related to > speeding things up. Patch 1 and 2 are tests; patch 15 is the speed-up change. Patches 3 through 14 all change the existing abstractions so that patch 15 can be small, and should have no impact. Patch 16 is a followup further cleanup enabled by 15. Only 15 should have any meaningful performance impact. >> 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. > > I don't think I have a clear idea of what will this mean in practice. > Can you show an example of its usage? There is a decent example on https://en.wikipedia.org/wiki/X_Macro In our case, it would be something like struct buffer { #define C_FIELD(field) Lisp_Object field; #define LISP_FIELD(field) Lisp_Object field; FIELD_LIST #undef C_FIELD #undef LISP_FIELD } #define C_FIELD(field) Lisp_Object bget_ ## (struct buffer *b) \ { return b->field ## _; } #define LISP_FIELD(field) Lisp_Object bget_ ## (struct buffer *b) \ { return bvar_get(b, offsetof(struct buffer, field)); } FIELD_LIST #undef C_FIELD #undef LISP_FIELD #define BVAR(b, field) bget_ ## field (b) >> 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? > > Is benchmark-run what you are after? Or are you asking what use cases > of buffer-local bindings to use inside the benchmark? If the latter, > then I guess some simple example with binding case-fold-search > followed by some regexp search would do, if you do that with various > numbers of live buffers in the session. Ah, no, I mean benchmarking the rest of Emacs to see the impact. I've already benchmarked these changes on the case they're intended to fix. Old results, but no change in this iteration: (benchmark-run 500000 (let ((case-fold-search nil)) (string-match "" ""))) ; unpatched emacs: (0.6872330339999999 0 0.0) ; patched emacs: (0.608068564 0 0.0) (setq my-buffer-list nil) (dotimes (idx 1000) (push (get-buffer-create (format "test-buffer:%s" idx)) my-buffer-list)) (benchmark-run 500000 (let ((case-fold-search nil)) (string-match "" ""))) ; unpatched emacs: (18.591189848 0 0.0) ; patched emacs: (0.5885462539999999 0 0.0)