From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: Excessive use of `eassert` Date: Fri, 19 Jan 2024 19:42:39 +0000 Message-ID: References: <83jzo5x0q8.fsf@gnu.org> <83sf2tv029.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17279"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Stefan Monnier , Paul Eggert , emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Jan 19 20:43:47 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 1rQumJ-0004N2-7T for ged-emacs-devel@m.gmane-mx.org; Fri, 19 Jan 2024 20:43:47 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rQulX-0005bQ-3C; Fri, 19 Jan 2024 14:42:59 -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 1rQulV-0005bF-HZ for emacs-devel@gnu.org; Fri, 19 Jan 2024 14:42:57 -0500 Original-Received: from mail.muc.de ([193.149.48.3]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rQulT-000503-H1 for emacs-devel@gnu.org; Fri, 19 Jan 2024 14:42:57 -0500 Original-Received: (qmail 83902 invoked by uid 3782); 19 Jan 2024 20:42:40 +0100 Original-Received: from acm.muc.de (pd953a818.dip0.t-ipconnect.de [217.83.168.24]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Fri, 19 Jan 2024 20:42:40 +0100 Original-Received: (qmail 29392 invoked by uid 1000); 19 Jan 2024 19:42:39 -0000 Content-Disposition: inline In-Reply-To: <83sf2tv029.fsf@gnu.org> X-Submission-Agent: TMDA/1.3.x (Ph3nix) X-Primary-Address: acm@muc.de Received-SPF: pass client-ip=193.149.48.3; envelope-from=acm@muc.de; helo=mail.muc.de 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, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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:315121 Archived-At: Hello, Eli. On Fri, Jan 19, 2024 at 17:02:06 +0200, Eli Zaretskii wrote: > > 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. Not really. Symbols with positions don't belong in the obarray. If they somehow get there, then that's a bug to be fixed. > 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. -- Alan Mackenzie (Nuremberg, Germany).