From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: master b0ba0d42b0f: * src/lisp.h (EQ): Improve generated code. Date: Thu, 28 Nov 2024 16:44:07 +0200 Message-ID: <86ttbrctag.fsf@gnu.org> References: <173279015204.1017853.4020802222494409378@vcs3.savannah.gnu.org> <20241128103552.86CC34F4FDB@vcs3.savannah.gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20609"; mail-complaints-to="usenet@ciao.gmane.io" Cc: acorallo@gnu.org, emacs-devel@gnu.org To: Pip Cet Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Nov 28 15:45:03 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 1tGflO-0005B4-6f for ged-emacs-devel@m.gmane-mx.org; Thu, 28 Nov 2024 15:45:02 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tGfkk-0003Us-TL; Thu, 28 Nov 2024 09:44:22 -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 1tGfkj-0003UE-LF for emacs-devel@gnu.org; Thu, 28 Nov 2024 09:44:21 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tGfkj-0000FV-D1; Thu, 28 Nov 2024 09:44:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=WfsAqONpBfzLzdhvkpoDg/X5Dp47ceMuQxe/5FgMNsk=; b=KylB6IIRp3E0 3l1pfiTnMRlFWRZtbKHZ8lRA2Wxi8dTf42nUzJ17pGMlLTS5wpYLtqVIruN2De9zFKXhz45rFdDsH iFXDjo7jPstLrbkXfGCmmN2ljvr765s//wlU1swHrdu8KXPXOzZT1EsTrEHWg52bxyy2J5hr70cZ0 /C7uzxhcDXyhB5y5YIWnCy+YLsoT32n1qMd9OiTzXOWhxHYM80nESaHjeS/DoQDs5C54IS1sW3SCe Pl+mtd1XvgqdXuCCiH6vzkOsgFfqvxqRTJmxBe0Hf+2OoVW3lNV5qoaQ3cuYhPEEO0/DkLhArBwNR 04hCdEy99Q2dDm1JldLmYw==; In-Reply-To: (emacs-devel@gnu.org) 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:325818 Archived-At: > Date: Thu, 28 Nov 2024 13:53:40 +0000 > Cc: Emacs Devel > From: Pip Cet via "Emacs development discussions." > > On Thursday, November 28th, 2024 at 10:35, Andrea Corallo wrote: > > > branch: master > > commit b0ba0d42b0fdf70a20cd7a070128db8abe4a0826 > > Author: Andrea Corallo acorallo@gnu.org > > > > Commit: Andrea Corallo acorallo@gnu.org > > > > > > * src/lisp.h (EQ): Improve generated code. > > > > Outside compilation 'symbols_with_pos_enabled' is always false, so ask > > the compiler to organize the most likely execution path in a sequential > > fashion in order to favor run-time performance. > > Are we officially using __builtin_expect now? > > I think that's a major change to the way Emacs C code is written, and a decision which might benefit from further discussion. > > To quote the GCC manual: > In general, you should prefer to use actual profile feedback for this (-fprofile-arcs), as programmers are notoriously bad at predicting how their programs actually perform. > > 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 preference, avoid using __builtin_expect entirely, so our scarce resources can be spent on more important issues? > > I also don't think the assumption you're telling GCC to make in this specific case (more than 90% of calls to EQ happen while syms_with_pos_enabled == false) is obviously correct. > > IIUC, the current master branch won't even compile with a compiler that doesn't handle (or ignore) __builtin_expect. I think we should us __builtin_expect only when building with GCC, indeed.