From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?=C3=93scar_Fuentes?= Newsgroups: gmane.emacs.devel Subject: Re: Improving EQ Date: Thu, 12 Dec 2024 11:42:48 +0100 Message-ID: <87ttb9xjvb.fsf@telefonica.net> References: <87h679kftn.fsf@protonmail.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="38384"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Pip Cet To: Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Dec 12 11:43:46 2024 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 1tLgfZ-0009rI-VC for ged-emacs-devel@m.gmane-mx.org; Thu, 12 Dec 2024 11:43:45 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tLgfJ-0007ns-R2; Thu, 12 Dec 2024 05:43:32 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tLgf5-0007fi-OL for emacs-devel@gnu.org; Thu, 12 Dec 2024 05:43:17 -0500 Original-Received: from relayout01.e.movistar.es ([86.109.101.201] helo=relayout01-redir.e.movistar.es) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tLgey-0003Za-OE for emacs-devel@gnu.org; Thu, 12 Dec 2024 05:43:14 -0500 Original-Received: from sky (125.red-83-37-187.dynamicip.rima-tde.net [83.37.187.125]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: 981711563@telefonica.net) by relayout01.e.movistar.es (Postfix) with ESMTPSA id 4Y88F45Mx2zfbJZ; Thu, 12 Dec 2024 11:42:48 +0100 (CET) In-Reply-To: <87h679kftn.fsf@protonmail.com> (Pip Cet via's message of "Wed, 11 Dec 2024 22:37:04 +0000") X-TnetOut-Country: IP: 83.37.187.125 | Country: ES X-TnetOut-Information: AntiSPAM and AntiVIRUS on relayout01 X-TnetOut-MsgID: 4Y88F45Mx2zfbJZ.A11EF X-TnetOut-SpamCheck: no es spam, clean X-TnetOut-From: ofv@wanadoo.es X-TnetOut-Watermark: 1734604971.27686@XphqEFPX/Zs5Sx09Sa/CDw Received-SPF: softfail client-ip=86.109.101.201; envelope-from=ofv@wanadoo.es; helo=relayout01-redir.e.movistar.es X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:326421 Archived-At: Pip Cet via "Emacs development discussions." writes: > I looked at the "new" code generated for our EQ macro, and decided that > a fix was in order. I'm therefore sending a first proposal to explain > what I think should be done, and some numbers. > > This patch: > * moves the "slow path" of EQ into a NO_INLINE function > * exits early if the arguments to EQ are actually BASE_EQ > * returns quickly (after a single memory access which cannot be avoided > until we fix our tagging scheme to distinguish exotic objects from > ordinary ones) when symbols_with_pos_enabled isn't true. > > The effect on the code size of the stripped emacs binary is small, but > significant: 8906336 bytes instead of 8955488 bytes on this machine. > (The effect on the code size of the emacs binary with debugging > information is much larger, reducing it from 32182000 bytes to 31125832 > bytes on this system.) There is no effect on the size of the .pdmp > file, which is expected. > > What's missing here is a benchmark, but unless there's a really nasty > surprise when that happens, I'm quite confident that we can improve the > code here. I've seen too many cases where *removing* instructions (mind you, literally removing, not changing!) made the code significantly slower. Modern CPUs are insanely complex and combined with compilers make intuition-based predictions even more futile. But reading your message makes me wonder if EQ and some other "simple" fundamental functions are not lowered by nativecomp? If not, maybe that's a significant opportunity for improvement. As for your patch, one thing that would be easy to do and might save quite a lot of head scratching is to count the fraction of the calls to EQ that benefit from the fast path on a "representative" Emacs run. Then you would have hard data to decide if fighting the compiler/CPU on that case is a worthy cause.