From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Arthur Miller Newsgroups: gmane.emacs.devel Subject: Re: 28.0.50; Proposal: slightly more efficient package-quickstart.el Date: Tue, 20 Jul 2021 08:01:03 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36402"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Jul 20 08:02:03 2021 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 1m5ipO-0009I2-PG for ged-emacs-devel@m.gmane-mx.org; Tue, 20 Jul 2021 08:02:03 +0200 Original-Received: from localhost ([::1]:57034 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m5ipN-0006Ox-Kv for ged-emacs-devel@m.gmane-mx.org; Tue, 20 Jul 2021 02:02:01 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33988) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5ioZ-0005iW-1L for emacs-devel@gnu.org; Tue, 20 Jul 2021 02:01:11 -0400 Original-Received: from mail-vi1eur05olkn2021.outbound.protection.outlook.com ([40.92.90.21]:36320 helo=EUR05-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5ioV-0000eb-J4 for emacs-devel@gnu.org; Tue, 20 Jul 2021 02:01:10 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gMJFbWMtJL2DKRTgs/sG0ztN8EMoRcLAzHQWdZXLZKN4Ow87jPl/Fm+dqv/7JRTE/9dPFNX9mdEvQYTiASSLT/mzFJ5R9k3OuVwhRXrNylNKL/MLGnUNgmxaLU9QkNp/I71xEnhG03squO5G6qF+blOPuKErQDy8aI+tUNK4ANfBeZqlcEOD7ZPtDZSMLdKhlZ6aEZCUV+u++D/539APnwUGWJGOx9QHru1Hoj8qmlNdxiTOZL5ihSVvnuG0bYN4jBvLk2kOLgu7zZgz//DEt5wcf0aU/hfkRIPrXfpCo7v4QV7Tqo7Fg64Vu1XgAu7B82dYU2rcRnyR3+AE2Sfyew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MIgQrDXtFuWSJ1YeAe6OielfeCxAKcNEzHyRPjQk/30=; b=IoAbRtphGPNie2e1vhSy0OH1dHd/RwZ2AxNQytwTClV2RuqRoGXQ0fWwCBV3UgYJsH8tCSh/cP7l8XDLimszkaiDyjSusPHnxDmjYx3kVplnZE9r+kLfcKFe8X5eP0u3KwSJ59SvN4pL97XPebaZ4u1fdK6qr7YsCokBVsfakrNDcgGXYN1gQNZwDnM4Wm2UdxRvhv7VKw7W5as9ZXluNUJI8od0vYEkvuna8ZH86EIDhTg3R6CZIr5YFerSVeDzrv3JVWbp+QGHiIv4e0fN9ro+KqtxhzaLX1Ngk32luPdTJhfBPhdBhXkbzBBo6gxWmBmgxh6rcrhK5kzZfbQLlg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=live.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MIgQrDXtFuWSJ1YeAe6OielfeCxAKcNEzHyRPjQk/30=; b=qXjDHNEgbPWJbPF2VtLDEm0jkIg0UX93gFi9WsScb6WZ2jB1asgCG0VyU4XYJAhJrMAx2mC3/RsOxXrqTAdR5WwXK4FgafXwMZtxkghn3nKBl2VHijRqWR/OA10B4z1q77cnolUX0WFRMKHNb3ID4D+rwLd2y0qypVjPGQVezrAYOK6DCscmnZ4bMIvoNMhlYOl1NETGg8hah72WafawX1mwQYQtPXh92oMbiXEH2m8e9kmdcgGQ9zvllHv+t+eiuE8n+bTs+6ifN72Mzl7Q8urNTy9xpPg+C2GrROdWVF0CaN+2bf+JQWs3iyCFmxIX3vmyF6D9WlHqxtZxDYmlHw== Original-Received: from VI1EUR05FT039.eop-eur05.prod.protection.outlook.com (2a01:111:e400:fc12::48) by VI1EUR05HT083.eop-eur05.prod.protection.outlook.com (2a01:111:e400:fc12::391) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21; Tue, 20 Jul 2021 06:01:04 +0000 Original-Received: from AM9PR09MB4977.eurprd09.prod.outlook.com (2a01:111:e400:fc12::45) by VI1EUR05FT039.mail.protection.outlook.com (2a01:111:e400:fc12::256) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Tue, 20 Jul 2021 06:01:04 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:59A88E1E333E5564D5635771AE52ADEF1889C9910DE0FB64DC1DC870D26967C1; UpperCasedChecksum:6840172858C738219E75120A8701B77DDEC0C5026923BC279F358939E21F569C; SizeAsReceived:7522; Count:46 Original-Received: from AM9PR09MB4977.eurprd09.prod.outlook.com ([fe80::e47b:760e:fa35:f28b]) by AM9PR09MB4977.eurprd09.prod.outlook.com ([fe80::e47b:760e:fa35:f28b%6]) with mapi id 15.20.4331.034; Tue, 20 Jul 2021 06:01:04 +0000 In-Reply-To: (Stefan Monnier's message of "Mon, 19 Jul 2021 22:54:01 -0400") X-TMN: [RKMp7N+lAkra+elYe2MjtzndWnsoJukK] X-ClientProxiedBy: AM5PR0701CA0070.eurprd07.prod.outlook.com (2603:10a6:203:2::32) To AM9PR09MB4977.eurprd09.prod.outlook.com (2603:10a6:20b:304::20) X-Microsoft-Original-Message-ID: <875yx5wmlc.fsf@live.com> X-MS-Exchange-MessageSentRepresentingType: 1 Original-Received: from pascal.homepc (81.232.177.30) by AM5PR0701CA0070.eurprd07.prod.outlook.com (2603:10a6:203:2::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.11 via Frontend Transport; Tue, 20 Jul 2021 06:01:03 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 46 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 3c6ced67-9178-4102-37b5-08d94b43c210 X-MS-TrafficTypeDiagnostic: VI1EUR05HT083: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yrsqBmEpEDoUTBGVxjL67Sf1v9a11C/eXrmcU//RT/Zzcunk7WRbAnlaH53YRpRqku3PZdz+Vk1XTtnrpTaXt4Dsl9rtQT2Avh0XZJ4cSHQTZFThFV0A3xEzAFor/qsFMO6DC3jzIFzwaRlgDBn1oH0pQ21HUpQ8A8iNH5x3MZghiwO9Qzkgwnh6/1Uh6dxDz4mG+T6mvywv57RcYGDTTsVtCJ7wC8hZozKPjl6afi6Q3oRF+rwSGPwZUD8h083HJV1a0S562mKJmhlhaNywEu75ZT1Jr9s+MVMS/PoJMMnk5K6jSExv0whynar0FrGWZQmutPoNn1+okUe762OtPsBijqoaPRX9+he6IE4cbA2bMAAuCkicdxDOhgZHYg+lPYiNkgym9kYKBXUHJXxpbntgjK/TJnuBv/0IyGwGlhRtoZDwyvMNWQFoLpaE67X7 X-MS-Exchange-AntiSpam-MessageData: ztMlhMJ4RxXcyS94DBypGGiyI6cFtKKdhlCFCJPtSwOWFm0vg/3eKUWAVmsTClmQhBU12wNdbzMyi3TcmyxskiZN7cQgWJdvHXLdKijRdW6xCR4xsZZlTTlD2LEzr3rxnNf2boWNGE8FRe+HYOyaHg== X-OriginatorOrg: live.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3c6ced67-9178-4102-37b5-08d94b43c210 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jul 2021 06:01:04.4323 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: VI1EUR05FT039.eop-eur05.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1EUR05HT083 Received-SPF: pass client-ip=40.92.90.21; envelope-from=arthur.miller@live.com; helo=EUR05-VI1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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:271372 Archived-At: Stefan Monnier writes: > Arthur Miller [2021-07-20 02:27:26] wrote: >> Since quickstart file is created by iterating through each and one >> installed package whose path is already known, this calculation can be >> performed once at generation time, rather than every time when Emacs >> starts. > > It's indeed an optimization we can perform. I'm not sure it's worth the > extra code, tho, since there's always a risk it will break something. > > Have you made some measurements to see if it the difference is > noticeable? Not so much, but it is not so much about noticable difference, more about not performing unnecessary computation. As the loop progresses, for every dir N, the loop does N-1 path comparisons. These are unnecessary comparisons since when we know for sure that the string is not added yet. Trend in Emacs seems to go towards having more and more packages installed. This removes N(N-1)) comparisons. >> - (Info-directory-list '(""))) >> + (Info-directory-list '("")) >> + paths) > > The GNU coding standard would call this `dirs` since a "path" is a list > of directories used for searching. I guess you could also call it > `path` (singular). Ok. >> @@ -4164,6 +4166,10 @@ >> (replace-match (if (match-end 1) "" pfile) t t))) >> (unless (bolp) (insert "\n")) >> (insert ")\n"))) >> + (goto-char (point-min)) >> + (while (re-search-forward "^(add-to-list.*load-path" nil t) >> + (goto-char (line-beginning-position)) >> + (kill-sexp)) >> (pp `(setq package-activated-list >> (append ',(mapcar #'package-desc-name package--quickstart-pkgs) >> package-activated-list)) > > Beside the hypothetical risk that the regexp matches an `add-to-list` to > an unrelated variable, I think this risks introducing real bugs for > packages which use (add-to-list 'load-path ) to add > *sub*directories. Yes, I was aware of it, but I am not sure how to write the regex, to avoid that risk. Maybe I could check if the path refers to itself. >> @@ -4175,6 +4181,10 @@ >> (setq Info-directory-list >> (append ',info-dirs Info-directory-list))) >> (current-buffer)))) >> + (goto-char (point-min)) >> + (forward-line 3) >> + (insert (concat "\n(nconc load-path '" (prin1-to-string paths) ")\n")) >> + (goto-char (point-max)) > > This inserts the dirs at the end of `load-path` whereas `add-to-list` > usually adds them to the beginning. I think this will break configs > where a newer version of Org is installed (because the built-in Org > will then take priority). Ok. I didn't notice anything on my own computer, but it says nothing about other people setups. Since nconc has to loop throug entire list to append to it's tail, I thought it is less to loop through existing load-path, since it probably contains only Emacs lisp directories at that point. But I can exchange the order. > Of course, we can fix those problems, but unless there's a compelling > performance argument, I think it's a waste of time. It's quite simple to do, it's not much of the code, Performance here is probably not spending cpu and saving battery life. I don't know, at least in theory :).