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: bug#30854: 27.0.50; Speeding up package.el startup Date: Mon, 21 Dec 2020 17:32:39 +0100 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23335"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Stefan Kangas , "emacs-devel@gnu.org" To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Dec 21 17:35:39 2020 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 1krO9q-0005vn-9H for ged-emacs-devel@m.gmane-mx.org; Mon, 21 Dec 2020 17:35:38 +0100 Original-Received: from localhost ([::1]:49840 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1krO9p-0002W6-7v for ged-emacs-devel@m.gmane-mx.org; Mon, 21 Dec 2020 11:35:37 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39486) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1krO7D-0000e6-NI for emacs-devel@gnu.org; Mon, 21 Dec 2020 11:32:55 -0500 Original-Received: from mail-am7eur06olkn2044.outbound.protection.outlook.com ([40.92.16.44]:34529 helo=EUR06-AM7-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 1krO73-0001un-10 for emacs-devel@gnu.org; Mon, 21 Dec 2020 11:32:55 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GcDvLiqtY7ZuaHnj7RbohFIKQoE+iELmfRYml0Jk6t0VieE3hNOFd5ROm1ZQolFO4k4ha9CUJrqQmPojbIhMBjmXyPh7uUvJf10MhJLlzuopYbrFZqRX0a4yY5qb52e+04C3GQABAlSo4+p/cFlZdPYuq4+usXtLg50KXNQAAmWZZsohEGmkz3o9H+rtMipoXOdzFNAmGegt4fnf7YQGnkukgio9xT7Usk2rO8r/MVQkfE+hFBkemIY7f/PJSqXQSFM2FjarWF4F7bYPmIUjySdlAHLHGF1dzNdvBIpyOre09B2qvTwK+GBLmRmtJEB3GKIAr0OiE5A79XBTT2S63g== 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=qvrtVIt6RrqgT2cEsFHxoThdbx5mwRsz9Uyu/iJ5zJo=; b=TuB1mLGx71DvTSXL+yRsdoV3OO1XyneMpmrUepUborB+tYWsL4+NuAGOoOZuZ5bW5e4WEiaqMNduDpfDQxeQdDFYfmqB5BIr9DTtKGVtIVLmLsXNjhizvz4m95Ejy6ZK2RzcxtOXLVb/o7+Yw2/8SMToBngHro4CpRbgRhhTnos2++xtRKai4ZizwhNrfl7c5WkO1ckNX9omvWkQpSUE59IPNom4SkUWLYR4fnWCMWJPBZjlHnyEUSDiK4FhjrMw4Y/DtgA9gebzTS/x35RXSed3JHRSuXmj4sfTPTnNDeCm632JxmrcBNr3ieuZk/wroRBl4uXWPWYVL8/dX28bIg== 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=qvrtVIt6RrqgT2cEsFHxoThdbx5mwRsz9Uyu/iJ5zJo=; b=swPsa/UyWfehO9xHlEkg6cvBiX53vBjAc/Yybsiv1r1sBRbAUynd0rL6f77pvR7EKMcskSIaBniznsf+TIHSuLdSRrgdTVUnLTdK+2TriiL8IYl0+8qiLnYhzNT+XDApbYhJkEW9YUUm0wEcJexK7siehh9CMGIMuABWZ4y2eRBahbkgW+5TXpAgwOamUUe9KqWv+xhMbakeX0aWSR5aGpLlPMgSwJBF4mzHjlSdNTl8XkXQj2dDEhUCusu/KN5KQZ7RG/EC5MysNMsywEc9buzt7aGbX5qGAN6+IQctcCEeMX35cysc2QOpS1cv+FuspJtfB21sel6/2kr349QGuQ== Original-Received: from AM7EUR06FT008.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::4a) by AM7EUR06HT079.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::487) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3676.22; Mon, 21 Dec 2020 16:32:41 +0000 Original-Received: from AM0PR06MB6577.eurprd06.prod.outlook.com (2a01:111:e400:fc36::43) by AM7EUR06FT008.mail.protection.outlook.com (2a01:111:e400:fc36::498) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3676.22 via Frontend Transport; Mon, 21 Dec 2020 16:32:41 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:BE06F304EA1AF9DD8B5DF2C377ECC2E4D6CD3FAC517476B0ABCC3CA4FB0D0424; UpperCasedChecksum:3BE266FA00F69BC09468457635EE46320C34CC7FE90A125D6179AC9019342992; SizeAsReceived:8349; Count:46 Original-Received: from AM0PR06MB6577.eurprd06.prod.outlook.com ([fe80::9487:8c7d:da00:4993]) by AM0PR06MB6577.eurprd06.prod.outlook.com ([fe80::9487:8c7d:da00:4993%8]) with mapi id 15.20.3676.033; Mon, 21 Dec 2020 16:32:41 +0000 In-Reply-To: (Stefan Monnier's message of "Sun, 20 Dec 2020 18:44:37 -0500") X-TMN: [PVWck6BtabYhf+z/DiMBedOjdxiQd7Dp] X-ClientProxiedBy: AS8PR04CA0010.eurprd04.prod.outlook.com (2603:10a6:20b:310::15) To AM0PR06MB6577.eurprd06.prod.outlook.com (2603:10a6:208:19a::23) X-Microsoft-Original-Message-ID: <87lfdr3ys8.fsf@live.com> X-MS-Exchange-MessageSentRepresentingType: 1 Original-Received: from pascal.homepc (90.230.29.56) by AS8PR04CA0010.eurprd04.prod.outlook.com (2603:10a6:20b:310::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3676.29 via Frontend Transport; Mon, 21 Dec 2020 16:32:39 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 46 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 8b9a272f-f56c-4111-c3dc-08d8a5ce0947 X-MS-TrafficTypeDiagnostic: AM7EUR06HT079: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nahFKTqYy+134SglUb8uCZSASZwMDq9fAGeb3dO6B53FPtJ92zDC6Y8WyRj9XApWfGlHxxrI2QY8IKrfdjLYOsacqSgKRCvwwmn0eGCExDuAliRfwLHkw1OSV+Uo0K5ismBtBN8BTfX0RFHtvtq/vMgwDII8lHvFS6ZW9UMX+OyfMf311LwJ5e61ZD9bMYtk+VSUJ7mbbUZGohnIK3yelSE31zRQf+nMKGnNfcfXlHirTQTiJ6uQw+ipYaQeL6pL X-MS-Exchange-AntiSpam-MessageData: tjdnpJZYS1DdCF/mxy/TUxAA8tO/elPZMah7G6++yW5FYdq5rjq2Waj8OykvT22A3sepg5q06lQoarm4hW9+buqx3gzL1ICN2/EyU+zjDzK1Zr2s5GM8/n5uIk+IKFFEqq7Y1IgOW/9HleX/OB8jaQ== X-OriginatorOrg: live.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Dec 2020 16:32:40.9344 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-Network-Message-Id: 8b9a272f-f56c-4111-c3dc-08d8a5ce0947 X-MS-Exchange-CrossTenant-AuthSource: AM7EUR06FT008.eop-eur06.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: AM7EUR06HT079 Received-SPF: pass client-ip=40.92.16.44; envelope-from=arthur.miller@live.com; helo=EUR06-AM7-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:261384 Archived-At: --=-=-= Content-Type: text/plain Stefan Monnier writes: >> Is there any reason to require package.el at startup at all? > > Yes: `package-activate-all` (called from `startup.el`). See if this is acceptable. I tried to make as few chagnes to package.el as possible, and I didn't wont to introduce a new file, so I just put the relevant files into startup.el. I am not sure about package--activated; if quicstart should set it to 't or not. I don't think is needed, and am not sure if it is straight wrong to do too in quickstart, so I don't do that. Seems to work for me, but I am never sure with Emacs :-). If that this change is acceptable I can write something short for the news file too. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=quickstart.patch >From 8c80ed0349a3c505d8410480885ffb46a4417ebc Mon Sep 17 00:00:00 2001 From: Arthur Miller Date: Mon, 21 Dec 2020 17:10:59 +0100 Subject: [PATCH] Refactored parts of package.el to startup.el for faster quickstart. --- lisp/emacs-lisp/package.el | 17 --------- lisp/startup.el | 73 +++++++++++++++++++++++++------------- 2 files changed, 49 insertions(+), 41 deletions(-) diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index fa93ffd0cc..36c1787216 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -609,11 +609,6 @@ package-alist loaded and/or activated, customize `package-load-list'.") (put 'package-alist 'risky-local-variable t) -(defvar package-activated-list nil - ;; FIXME: This should implicitly include all builtin packages. - "List of the names of currently activated packages.") -(put 'package-activated-list 'risky-local-variable t) - ;;;; Populating `package-alist'. ;; The following functions are called on each installed package by @@ -1574,10 +1569,6 @@ package-read-all-archive-contents (defvar package--initialized nil "Non-nil if `package-initialize' has been run.") -;;;###autoload -(defvar package--activated nil - "Non-nil if `package-activate-all' has been run.") - ;;;###autoload (defun package-initialize (&optional no-activate) "Load Emacs Lisp packages, and activate them. @@ -1608,8 +1599,6 @@ package-initialize ;; `package--initialized' is t. (package--build-compatibility-table)) -(defvar package-quickstart-file) - ;;;###autoload (defun package-activate-all () "Activate all installed packages. @@ -4034,12 +4023,6 @@ package-quickstart :type 'boolean :version "27.1") -(defcustom package-quickstart-file - (locate-user-emacs-file "package-quickstart.el") - "Location of the file used to speed up activation of packages at startup." - :type 'file - :version "27.1") - (defun package--quickstart-maybe-refresh () (if package-quickstart ;; FIXME: Delay refresh in case we're installing/deleting diff --git a/lisp/startup.el b/lisp/startup.el index b1128f6d02..25f949bf44 100644 --- a/lisp/startup.el +++ b/lisp/startup.el @@ -1224,34 +1224,59 @@ command-line "early-init.el" startup-init-directory))) (setq early-init-file user-init-file) - + + (defcustom package-quickstart-file + (locate-user-emacs-file "package-quickstart.el") + "Location of the file used to speed up activation of packages at startup." + :type 'file + :version "27.1") + + (defvar package--activated nil + "Non-nil if `package-activate-all' has been run.") + + (defvar package-activated-list nil + ;; FIXME: This should implicitly include all builtin packages. + "List of the names of currently activated packages.") + (put 'package-activated-list 'risky-local-variable t) + ;; If any package directory exists, initialize the package system. (and user-init-file package-enable-at-startup (not (bound-and-true-p package--activated)) - (catch 'package-dir-found - (let (dirs) - (if (boundp 'package-directory-list) - (setq dirs package-directory-list) - (dolist (f load-path) - (and (stringp f) - (equal (file-name-nondirectory f) "site-lisp") - (push (expand-file-name "elpa" f) dirs)))) - (push (if (boundp 'package-user-dir) - package-user-dir - (locate-user-emacs-file "elpa")) - dirs) - (dolist (dir dirs) - (when (file-directory-p dir) - (dolist (subdir (directory-files dir)) - (when (let ((subdir (expand-file-name subdir dir))) - (and (file-directory-p subdir) - (file-exists-p - (expand-file-name - (package--description-file subdir) - subdir)))) - (throw 'package-dir-found t))))))) - (package-activate-all)) + ;; If quickstart file exists, just load it + (if (file-readable-p (expand-file-name package-quickstart-file)) + ;; Skip load-source-file-function which would slow us down by a factor + ;; 2 (this assumes we were careful to save this file so it doesn't need + ;; any decoding). + (let ((load-source-file-function nil)) + ;;(setq package--activated t) + (load package-quickstart-file nil 'nomessage)) + ;; When quickstart file is not found, we do business as + ;; usual + (progn + (catch 'package-dir-found + (let (dirs) + (if (boundp 'package-directory-list) + (setq dirs package-directory-list) + (dolist (f load-path) + (and (stringp f) + (equal (file-name-nondirectory f) "site-lisp") + (push (expand-file-name "elpa" f) dirs)))) + (push (if (boundp 'package-user-dir) + package-user-dir + (locate-user-emacs-file "elpa")) + dirs) + (dolist (dir dirs) + (when (file-directory-p dir) + (dolist (subdir (directory-files dir)) + (when (let ((subdir (expand-file-name subdir dir))) + (and (file-directory-p subdir) + (file-exists-p + (expand-file-name + (package--description-file subdir) + subdir)))) + (throw 'package-dir-found t))))))) + (package-activate-all)))) ;; Make sure window system's init file was loaded in loadup.el if ;; using a window system. -- 2.29.2 --=-=-=--