From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Skipping unexec via a big .elc file Date: Tue, 25 Oct 2016 09:48:00 -0400 Message-ID: References: <83h98nidvd.fsf@gnu.org> <87eg3rvtsf.fsf@users.sourceforge.net> <83k2dihpm9.fsf@gnu.org> <8760p2wzgj.fsf@users.sourceforge.net> <838ttyhhzu.fsf@gnu.org> <871szqwu51.fsf@users.sourceforge.net> <831szqhbc2.fsf@gnu.org> <87d1itt79z.fsf_-_@users.sourceforge.net> <7baa18d4-2b09-caa8-005e-29008a383ad1@cs.ucla.edu> <83mvhwrgd5.fsf@gnu.org> <8539f38f-9a11-44c3-4de7-bb974c96206c@cs.ucla.edu> <8360ojpndr.fsf@gnu.org> <83shrnm0k1.fsf@gnu.org> <075B0922-F07A-4FBA-AE71-027E964A5ED4@raeburn.org> <54AAC13A-CF56-4393-A932-DC6CBBF51259@raeburn.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1477404025 32034 195.159.176.226 (25 Oct 2016 14:00:25 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 25 Oct 2016 14:00:25 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2.50 (gnu/linux) Cc: Eli Zaretskii , emacs-devel@gnu.org To: Ken Raeburn Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Oct 25 16:00:15 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bz2Gz-0007DW-Fe for ged-emacs-devel@m.gmane.org; Tue, 25 Oct 2016 16:00:13 +0200 Original-Received: from localhost ([::1]:54709 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bz2H1-0000H9-Rz for ged-emacs-devel@m.gmane.org; Tue, 25 Oct 2016 10:00:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33997) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bz25L-0007np-J5 for emacs-devel@gnu.org; Tue, 25 Oct 2016 09:48:12 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bz25K-0004y1-Is for emacs-devel@gnu.org; Tue, 25 Oct 2016 09:48:11 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:35779) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1bz25F-0004xL-03; Tue, 25 Oct 2016 09:48:05 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0DyAQALW9BX/1qOs2tdGgEBAQECAQEBAYMtAQEBAQEehE2FUIRlqxGCA4YWBAICgWk5FAECAQEBAQEBAV4nhGIBAQMBIzMjBQsLGgIYDgICFBgNJIhVCLA1jCABAQgngQWJeIRAgwKCPR0FlAyFTZErh2IxhVqQSx42gmgbgWkghgoBAQE X-IPAS-Result: A0DyAQALW9BX/1qOs2tdGgEBAQECAQEBAYMtAQEBAQEehE2FUIRlqxGCA4YWBAICgWk5FAECAQEBAQEBAV4nhGIBAQMBIzMjBQsLGgIYDgICFBgNJIhVCLA1jCABAQgngQWJeIRAgwKCPR0FlAyFTZErh2IxhVqQSx42gmgbgWkghgoBAQE X-IronPort-AV: E=Sophos;i="5.30,296,1470715200"; d="scan'208";a="277045622" Original-Received: from 107-179-142-90.cpe.teksavvy.com (HELO ceviche.home) ([107.179.142.90]) by smtp.teksavvy.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 25 Oct 2016 09:48:00 -0400 Original-Received: by ceviche.home (Postfix, from userid 20848) id 64E226622D; Tue, 25 Oct 2016 09:48:00 -0400 (EDT) In-Reply-To: <54AAC13A-CF56-4393-A932-DC6CBBF51259@raeburn.org> (Ken Raeburn's message of "Tue, 25 Oct 2016 05:02:33 -0400") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.181 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:208762 Archived-At: >>> Did you check whether actually byte compiling the written file made >>> a difference? >> dumped.elc has no code to compile. > It has a lot of fset and setplist calls which can be compiled, especially= if > you reorder things such that they=E2=80=99re not mixed up with the defvar= calls that > don=E2=80=99t compile. "A lot of" is relative: the time to read them compared to an equivalent byte-code version should be negligeable, and their execution time should be even more negligeable. > The generated .elc output is about 25% larger. That's not because of byte-compilation per-se. It's because the byte-compiler uses `print-circle' but only within each top-level entity, so you lose sharing between functions and between variables. IOW you can get the exact same 25% larger file by printing each fset/defvar/setplist separately (instead of printing them as one big `progn`). And you can trick the byte-compiler to preserve this sharing by replacing the leading `progn` (which the byte-compiler removes) into a (let () ...), tho maybe you'll need to really add some dummy binding in that `let` to make sure the byte-compiler doesn't end up removing it. > I did some profiling. Without byte compiling, it appears that around half > of the CPU time used loading the file in my test is spent in > Frassq(=E2=80=A6,read_objects), called from substitute_object_recurse. Ah, that's what it is. Clearly we should be able to optimize most of this away. > For processing a file with this much sharing of objects, an assoc list wi= th > O(n) access time may not be the best choice. Indeed. > Whatever we replace it with, it appears we need to be able to look up > cons cells in a collection by either element. Ideally, we could get rid of substitute_object_in_subtree entirely. E.g. the patch below skips it for the case of "#n=3D(...)", and by peeping ahead to decide the type of placeholder we build, we should be able to get rid of it in all cases. Stefan diff --git a/src/lread.c b/src/lread.c index 58d518c..a06a78f 100644 --- a/src/lread.c +++ b/src/lread.c @@ -2936,12 +2936,21 @@ read1 (Lisp_Object readcharfun, int *pch, bool firs= t_in_list) tem =3D read0 (readcharfun); =20 /* Now put it everywhere the placeholder was... */ - substitute_object_in_subtree (tem, placeholder); + if (CONSP (tem)) + { + Fsetcar (placeholder, XCAR (tem)); + Fsetcdr (placeholder, XCDR (tem)); + return placeholder; + } + else + { + substitute_object_in_subtree (tem, placeholder); =20 - /* ...and #n# will use the real value from now on. */ - Fsetcdr (cell, tem); + /* ...and #n# will use the real value from now on. */ + Fsetcdr (cell, tem); =20 - return tem; + return tem; + } } =20 /* #n# returns a previously read object. */