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: Circular records: how do I best handle them? (The new correct warning position branch now bootstraps in native compilation!) Date: Fri, 7 Jan 2022 16:44:40 +0000 Message-ID: References: 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="13461"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Jan 07 17:47:37 2022 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 1n5sOu-0003Dy-QH for ged-emacs-devel@m.gmane-mx.org; Fri, 07 Jan 2022 17:47:36 +0100 Original-Received: from localhost ([::1]:34012 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n5sOs-0004HJ-Vd for ged-emacs-devel@m.gmane-mx.org; Fri, 07 Jan 2022 11:47:34 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:38528) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n5sML-00024b-6U for emacs-devel@gnu.org; Fri, 07 Jan 2022 11:44:57 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:16290 helo=mail.muc.de) by eggs.gnu.org with smtp (Exim 4.90_1) (envelope-from ) id 1n5sMI-0000DY-5I for emacs-devel@gnu.org; Fri, 07 Jan 2022 11:44:56 -0500 Original-Received: (qmail 2212 invoked by uid 3782); 7 Jan 2022 16:44:41 -0000 Original-Received: from acm.muc.de (p4fe157e5.dip0.t-ipconnect.de [79.225.87.229]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Fri, 07 Jan 2022 17:44:41 +0100 Original-Received: (qmail 4919 invoked by uid 1000); 7 Jan 2022 16:44:40 -0000 Content-Disposition: inline In-Reply-To: X-Submission-Agent: TMDA/1.3.x (Ph3nix) X-Primary-Address: acm@muc.de Received-SPF: pass client-ip=193.149.48.1; envelope-from=acm@muc.de; helo=mail.muc.de X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, PLING_QUERY=0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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" Xref: news.gmane.io gmane.emacs.devel:284426 Archived-At: Hello, Stefan. On Sat, Jan 01, 2022 at 12:31:51 -0500, Stefan Monnier wrote: [ .... ] > > What I bumped into was circularly linked vectors in the source code > > being compiled. > Then my question above turns into: what is this source code? > > I've amended the reader so that it doesn't put positions on symbols > > which are read as components of other structures such as byte compiled > > functions, text property lists in strings, and so on. (Actually, there > > was very little to amend.). > OK. > >> > The positions get stripped before the code is dumped to the .elc. > >> Why bother? You can just have a `print-symbols-without-position` which > >> you let-bind around the printing code. > > I think I've got that already, though it's a long time since I looked at > > it. > So why do you need to strip the positions before dumping the code into > the `.elc`? Thank you very much indeed for this tip. I don't need to strip the positions. eval already handles symbols with position (provided symbols-with-pos-enabled is non-nil), as does pretty much everything else, including the native-compiler. Binding that variable and print-symbols-bare to non-nil rather than stripping positions was actually quite simple, compared with the mess I was in trying to deal with the circularity in some of the lists/vectors/records. I profiled some of the compilation runs with the stripping strategy, and garbage collection was consuming around 70% of the run time. :-( I've now got the thing working modulo tidying up. A make bootstrap now takes 7min 45sec on my machine, compared with 7min 18sec for the same on the master branch. That's a 7% difference. However, I've still got to strip out the old warning position mechanism, which should shave something off of that 7% difference. [ .... ] > `put` and `puthash` are just some of the ways a macro's arg can > "escape". A macro may also something like > (push arg my-list-of-stuff) > Having to strip symbol positions in `put` and `puthash` (i.e. having > this implementation detail leak to those places which aren't directly > related to compilation) is pretty ugly. Do we really want to extend > that to `setq`, `aset`, and whatnot? No. What we have to do is NOT to strip positions off of these objects, instead warning users to be careful about saving bits of code in a way that survives the byte compilation. Possibly we should give them the position stripping function to use at their discretion. What do you think? [ .... ] > Stefan -- Alan Mackenzie (Nuremberg, Germany).