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: Excessive use of `eassert` Date: Fri, 19 Jan 2024 17:02:06 +0200 Message-ID: <83sf2tv029.fsf@gnu.org> References: <83jzo5x0q8.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7924"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Stefan Monnier , Paul Eggert , Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Jan 19 16:03:33 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 1rQqP7-0001rL-Ci for ged-emacs-devel@m.gmane-mx.org; Fri, 19 Jan 2024 16:03:33 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rQqOE-0007aB-IK; Fri, 19 Jan 2024 10:02:38 -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 1rQqOA-0007ZZ-QA for emacs-devel@gnu.org; Fri, 19 Jan 2024 10:02:35 -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 1rQqO8-0003P6-9c; Fri, 19 Jan 2024 10:02:33 -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=ai8w83EQ7cQfJrlVJeb33bDhcZXI1M3I99Cq0+iLR/g=; b=TsbMsfpoZHg3 D6yJnQ8FeJNJdrerTVi7mq6fOr671FgN1mgIhXlceExJQrY6iNzKVffLdCNGKXwYctAn8QPxHc1rF wF+1KHH5jOHz8jtEkdANLYdxbi4nWshZS9MtqWzeVlJuZCrptd0ZFhH4pm6cJuKlkcLDkBSxGU00B 9Tp2nl238UqiO7i4g+bp40Xqbn9tx6omkrZi0xExy2CRYbDrFmS8OKmCBfs/RQTvAvJvfTsvD0lj6 ymc/x5xkqX0u0Mmu//ej+z3mM7DXi1ZZveQkqEvjyyUYBH1GhHLFqJG195EmhBWN9pIfgwp60BnbC zOWbj5p8iQXvEH4Nm1qP8Q==; In-Reply-To: (message from Stefan Monnier on Fri, 19 Jan 2024 08:01:47 -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:315113 Archived-At: > From: Stefan Monnier > Cc: emacs-devel@gnu.org > Date: Fri, 19 Jan 2024 08:01:47 -0500 > > >> shows that `make_lisp_symbol` is not inlined, so NILP(x) ends up being > >> an actual function call to a function calling another function .... > >> which I think is definitely in the "excessive" camp :-) > > > > I'm not sure I follow. Can you elaborate? Are you saying that the > > assertion causes make_lisp_symbol not to be inlined? And what > > functions are called by NILP? > > AFAICT it's worse than just `NILP`, I think, because every `Qnil` (same > thing with all other `Q`, I guess) becomes a call to > `builtin_lisp_symbol` which itself has a call to `make_lisp_symbol`. Then how come this is suddenly an issue? We've had that assertion since 2016. I use an Emacs build with ENABLE_CHECKING and without optimizations every day, and while it is indeed slower than the production build by a factor of 3.5, it is not unbearably slow. > >> The patch below seems to address this specific issue, tho I haven't > >> measured its performance impact yet. > > Is this specifically about NILP? Or are there other situations where > > this assertion slows us down considerably. I wouldn't want to drop > > this assertion so summarily, if possible. > > Why do you find this specific assertion important? When building other > `Lisp_Object`s (like `make_fixnum`) we don't seem to have any > corresponding assertion that the revere operation (e.g. XFIXNUM) returns > the original value. make_fixnum is a trivial bit-shuffling, whereas make_lisp_symbol is much trickier. Perhaps especially so now that we have symbols-with-positions as well as bare symbols. I have added Paul, who introduced that assertion (and the code around it). Paul, do you think this assertion is important to keep? I also added Alan, in case he has comments.