From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Pip Cet via "Emacs development discussions." Newsgroups: gmane.emacs.devel Subject: Re: master b0ba0d42b0f: * src/lisp.h (EQ): Improve generated code. Date: Thu, 28 Nov 2024 20:14:21 +0000 Message-ID: References: <173279015204.1017853.4020802222494409378@vcs3.savannah.gnu.org> <20241128103552.86CC34F4FDB@vcs3.savannah.gnu.org> <8BCABD6D-6605-438C-A62D-B7DA42D07AD4@gmail.com> Reply-To: Pip Cet Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26914"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Andrea Corallo , Emacs Devel To: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Nov 29 07:55:21 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 1tGuuP-0006q7-0E for ged-emacs-devel@m.gmane-mx.org; Fri, 29 Nov 2024 07:55:21 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tGuta-0003j9-MN; Fri, 29 Nov 2024 01:54:30 -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 1tGkuF-0000rv-9I for emacs-devel@gnu.org; Thu, 28 Nov 2024 15:14:31 -0500 Original-Received: from mail-40133.protonmail.ch ([185.70.40.133]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tGkuD-0001An-6X; Thu, 28 Nov 2024 15:14:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1732824863; x=1733084063; bh=Iuk6/h/ah8NjHjLOOsmqdAgkNP6QGLGEeFhzDdPDZAQ=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post; b=mEyXeI9ZQt+FApVAHZKFvJjCIdXvpZYSWdlT0FZNYv96Oht8Up5g45XhsBTnfdGIa SDNPLOxMoQCnzXDdR/GFPx23n2+kAOa4N5JU14nVX5aUSs1JxoRYV5SSzkvkA5J2bN anw1UOscFHHdlnb4nA9Ay3x54Rsi2KPPjfuZaEkUxOiB0RN0YcGJc6uPNO4ZxixMLz yX9WizQ+f11+6t/mbw1r+7kEZrqpC1C7Qqbnji8g3HSfnpuzl3nmysCuQynx0OwQFy OPF9j5LoLT3JGl0KrSH8Um7SnByB5Cbm4ARhCiU6NUlcFMkDUhdbRUpZ0SSYk4+rGn bfgZGoOEbhzjw== In-Reply-To: <8BCABD6D-6605-438C-A62D-B7DA42D07AD4@gmail.com> Feedback-ID: 112775352:user:proton X-Pm-Message-ID: 5f7dd8a765794d01353580aa78fb18d54b2130f0 Received-SPF: pass client-ip=185.70.40.133; envelope-from=pipcet@protonmail.com; helo=mail-40133.protonmail.ch 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, FREEMAIL_FROM=0.001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Fri, 29 Nov 2024 01:54:28 -0500 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:325841 Archived-At: On Thursday, November 28th, 2024 at 17:53, Mattias Engdeg=C3=A5rd wrote: > 28 nov. 2024 kl. 14.53 skrev Pip Cet via Emacs development discussions. e= macs-devel@gnu.org: >=20 > > Maybe we should use __builtin_expect_with_probability instead, in those= rare cases when we are certain we're making a correct prediction? Or, my p= reference, avoid using __builtin_expect entirely, so our scarce resources c= an be spent on more important issues? >=20 > Actually __builtin_expect can definitely provide a measurable performance= improvement, If we want that improvement, let's use a profile-guided build. No need to r= educe the legibility of our C code further by using a GCC extension which i= s largely obsoleted by PGO and __builtin_expect_with_probability. > mainly for BB ordering and cold-path moving as suggested by Andrea's comm= it note. I've been thinking about using it in other cases. I think we should heed the warning in the GCC manual: it is very hard to ge= t a good grasp of whether __builtin_expect provides any benefit. > We should probably define some variant of likely/unlikely because those c= over most needs of __builtin_expect, rather than using it directly. Then po= rtability wouldn't be a problem. That's what the Android code already does, IIUC. I don't think that solves = any problems, because the compiler uses a 90% probability for __builtin_exp= ect, and "likely" is simply misleading for that. > > I also don't think the assumption you're telling GCC to make in this sp= ecific case (more than 90% of calls to EQ happen while syms_with_pos_enable= d =3D=3D false) is obviously correct. >=20 > On this point I agree -- this particular change may have been made in has= te, although I applaud the spirit. So let's discuss this if and when a real usecase for __builtin_expect arise= s, and we conclude that use case couldn't be addressed by PGO? Pip