From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.bugs Subject: bug#35909: 27.0.50; Speed up untarring (and hence package installation) Date: Sat, 25 May 2019 20:24:46 -0400 Message-ID: <87ef4m83ld.fsf@gmail.com> References: <87h89i84q5.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="156302"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) To: 35909@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun May 26 02:27:37 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hUh0i-000eYY-DK for geb-bug-gnu-emacs@m.gmane.org; Sun, 26 May 2019 02:27:36 +0200 Original-Received: from localhost ([127.0.0.1]:48524 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hUh0g-0002b0-VO for geb-bug-gnu-emacs@m.gmane.org; Sat, 25 May 2019 20:27:35 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:47164) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hUh0X-0002YW-CA for bug-gnu-emacs@gnu.org; Sat, 25 May 2019 20:27:27 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hUgyE-0003JD-R9 for bug-gnu-emacs@gnu.org; Sat, 25 May 2019 20:25:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:36405) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hUgyE-0003J9-Jn for bug-gnu-emacs@gnu.org; Sat, 25 May 2019 20:25:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hUgyE-0004EM-DU for bug-gnu-emacs@gnu.org; Sat, 25 May 2019 20:25:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 26 May 2019 00:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 35909 X-GNU-PR-Package: emacs Original-Received: via spool by 35909-submit@debbugs.gnu.org id=B35909.155883030016246 (code B ref 35909); Sun, 26 May 2019 00:25:02 +0000 Original-Received: (at 35909) by debbugs.gnu.org; 26 May 2019 00:25:00 +0000 Original-Received: from localhost ([127.0.0.1]:49949 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hUgyB-0004Ds-BP for submit@debbugs.gnu.org; Sat, 25 May 2019 20:24:59 -0400 Original-Received: from mail-it1-f179.google.com ([209.85.166.179]:54622) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hUgy6-0004DW-RB; Sat, 25 May 2019 20:24:55 -0400 Original-Received: by mail-it1-f179.google.com with SMTP id h20so21623515itk.4; Sat, 25 May 2019 17:24:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:references:date:in-reply-to:message-id:user-agent :mime-version; bh=hjwl0dKLO3zS9ig9pJHXyA5LUCd0t9ZBXPPvLEiYPq4=; b=X/uFr4wr8I9x2OSqFHwRWbYNBiPrwhgDgrP/LSgZO0hvsoePNm1rSEAVe8/poV6eJS aRl0ARygISDm/b1Tr3Tagiu1pCZBxGYw5o6pL/E3zKFutJWGDVwvi0kRawVAeKyDIfdC zeWZTJNDVWHJJXGFhVi8r9Me/t7OcoY4vIOcyPHdret9CtKHb4OoHLOlCI7Cnnc7YgB3 3GE9Rp/hiAYJbAn7142h5asrWcqJ7OQA/mgBdE/QNIPTidqbQL6EiW00qZsEVjNq8me1 5FVW+G5R/+iN9rIvHwzXWUkmoMS15DGYcRQk3PdcDjeXooO3flQhyCtVNPjMCmP4esBf OmDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=hjwl0dKLO3zS9ig9pJHXyA5LUCd0t9ZBXPPvLEiYPq4=; b=VJEi5aghpJ4CCMjQhRADBuAG+20c7hFwJON8yrSqWMbeJaHajDRproommL1BUx+4kV ey2emzthTY+l3qRX2ef4XMwgOOn5UpBJOF/r4drQNUymV8wz2t9/3HdxXkYHDYQmMhR4 ABamzBeY2bOTDJeY7EU7ffVcYiikYZMr9aJAUFJgUlqWBGW/KwR3hxYl4RwXfbkCyQvI sTOJi9mlbmw/51Z/IydFATzLSMkqLnmY3Ka6Gv86yBc+5RWx3N9PtWnY8qf6+UGIqZtH CVxIX7BWReFSJuJTzCvZ2BPf96YvgWIa7vir52PWQNATWX47XElO4OX2aBQy4ZL7FbAm ES4A== X-Gm-Message-State: APjAAAWdhMA62OdxtR/+75i8ryxSJBYTWMOOXNqcQL+i339SCuU9VnaA lEuYu6FbvdZOm9gkMWH8CbM6CkDs X-Google-Smtp-Source: APXvYqwHv4dZAwyDD911K+OybnB+20S79g0w5NmoOVJAZiUQ7nMhL+E2xagatBFkv56C/vIHloYEHg== X-Received: by 2002:a24:6583:: with SMTP id u125mr23824110itb.168.1558830289114; Sat, 25 May 2019 17:24:49 -0700 (PDT) Original-Received: from minid (cbl-45-2-119-34.yyz.frontiernetworks.ca. [45.2.119.34]) by smtp.gmail.com with ESMTPSA id v25sm2464741ioh.81.2019.05.25.17.24.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 25 May 2019 17:24:48 -0700 (PDT) In-Reply-To: <87h89i84q5.fsf@gmail.com> (Noam Postavsky's message of "Sat, 25 May 2019 20:00:18 -0400") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:159775 Archived-At: --=-=-= Content-Type: text/plain tags 35909 + patch quit > package.el uses tar-mode.el to unpack tar files. This can be very slow > for tar files which have many small files. As an example see > https://elpa.gnu.org/packages/yasnippet-classic-snippets-1.0.2.tar. > > tar-untar-buffer for that file currently takes 11.5 seconds on my > machine. After (setq write-region-inhibit-fsync t) it takes 1.2 > seconds. When further binding inhibit-message to t around the call, it > takes 0.3 seconds. Which is the same as running tar -xf. The patch replaces message with (an enhanced) progress-reporter-update rather than using inhibit-message. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Let-untarring-and-hence-package-installation-go-fast.patch Content-Description: patch >From dba330e96a99e20a57ce4a1efd3d5851dcdfb6ae Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sat, 25 May 2019 19:44:41 -0400 Subject: [PATCH] Let untarring (and hence package installation) go faster (Bug#35909) * lisp/subr.el (progress-reporter-update) (progress-reporter-force-update, progress-reporter-do-update): Accept new optional argument, SUFFIX. * doc/lispref/display.texi (Progress): Document it. * etc/NEWS: Announce it. * lisp/tar-mode.el (tar-untar-buffer): Use a progress reporter instead of calling message. Suppress message from write-region. Let-bind write-region-inhibit-fsync to t. --- doc/lispref/display.texi | 11 ++++++++--- etc/NEWS | 4 ++++ lisp/subr.el | 49 ++++++++++++++++++++++++++++++------------------ lisp/tar-mode.el | 13 ++++++++----- 4 files changed, 51 insertions(+), 26 deletions(-) diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi index a2ed4b3891..22b9b7ff0b 100644 --- a/doc/lispref/display.texi +++ b/doc/lispref/display.texi @@ -426,7 +426,7 @@ Progress message is printed immediately. @end defun -@defun progress-reporter-update reporter &optional value +@defun progress-reporter-update reporter &optional value suffix This function does the main work of reporting progress of your operation. It displays the message of @var{reporter}, followed by progress percentage determined by @var{value}. If percentage is zero, @@ -440,6 +440,11 @@ Progress @code{make-progress-reporter}. For instance, if you scan a buffer, then @var{value} should be the result of a call to @code{point}. +Optional argument @var{suffix} is a string to be displayed after +@var{reporter}'s main message and progress text. If REPORTER is a +non-numerical reporter, then @var{value} should be @code{nil}, or a +string to use instead of @var{suffix}. + This function respects @var{min-change} and @var{min-time} as passed to @code{make-progress-reporter} and so does not output new messages on every invocation. It is thus very fast and normally you should not @@ -447,11 +452,11 @@ Progress likely negate your effort. @end defun -@defun progress-reporter-force-update reporter &optional value new-message +@defun progress-reporter-force-update reporter &optional value new-message suffix This function is similar to @code{progress-reporter-update} except that it prints a message in the echo area unconditionally. -The first two arguments have the same meaning as for +@var{reporter}, @var{value}, and @var{suffix} have the same meaning as for @code{progress-reporter-update}. Optional @var{new-message} allows you to change the message of the @var{reporter}. Since this function always updates the echo area, such a change will be immediately diff --git a/etc/NEWS b/etc/NEWS index 8e8172a81b..99d8d2ad10 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -370,6 +370,10 @@ in tooltips, as it is not useful there. There are 2 new buffer local variables and 1 face to customize this mode they are described in the manual "(emacs) Display". ++++ +** 'progress-reporter-update' accepts a suffix string to display. + + * Editing Changes in Emacs 27.1 diff --git a/lisp/subr.el b/lisp/subr.el index c97d9b96bd..bde4db192e 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -5010,7 +5010,8 @@ set-transient-map ;; MAX-VALUE ;; MESSAGE ;; MIN-CHANGE -;; MIN-TIME]) +;; MIN-TIME +;; MESSAGE-SUFFIX]) ;; ;; This weirdness is for optimization reasons: we want ;; `progress-reporter-update' to be as fast as possible, so @@ -5020,7 +5021,7 @@ set-transient-map ;; digits of precision, it doesn't really matter here. On the other ;; hand, it greatly simplifies the code. -(defsubst progress-reporter-update (reporter &optional value) +(defsubst progress-reporter-update (reporter &optional value suffix) "Report progress of an operation in the echo area. REPORTER should be the result of a call to `make-progress-reporter'. @@ -5029,14 +5030,17 @@ progress-reporter-update `make-progress-reporter'---then VALUE should be a number between MIN-VALUE and MAX-VALUE. -If REPORTER is a non-numerical reporter, VALUE should be nil. +Optional argument SUFFIX is a string to be displayed after +REPORTER's main message and progress text. If REPORTER is a +non-numerical reporter, then VALUE should be nil, or a string to +use instead of SUFFIX. This function is relatively inexpensive. If the change since last update is too small or insufficient time has passed, it does nothing." (when (or (not (numberp value)) ; For pulsing reporter (>= value (car reporter))) ; For numerical reporter - (progress-reporter-do-update reporter value))) + (progress-reporter-do-update reporter value suffix))) (defun make-progress-reporter (message &optional min-value max-value current-value min-change min-time) @@ -5080,26 +5084,28 @@ make-progress-reporter max-value message (if min-change (max (min min-change 50) 1) 1) - min-time)))) + min-time + ;; SUFFIX + nil)))) (progress-reporter-update reporter (or current-value min-value)) reporter)) -(defun progress-reporter-force-update (reporter &optional value new-message) +(defun progress-reporter-force-update (reporter &optional value new-message suffix) "Report progress of an operation in the echo area unconditionally. -The first two arguments are the same as in `progress-reporter-update'. +REPORTER, VALUE, and SUFFIX are the same as in `progress-reporter-update'. NEW-MESSAGE, if non-nil, sets a new message for the reporter." (let ((parameters (cdr reporter))) (when new-message (aset parameters 3 new-message)) (when (aref parameters 0) (aset parameters 0 (float-time))) - (progress-reporter-do-update reporter value))) + (progress-reporter-do-update reporter value suffix))) (defvar progress-reporter--pulse-characters ["-" "\\" "|" "/"] "Characters to use for pulsing progress reporters.") -(defun progress-reporter-do-update (reporter value) +(defun progress-reporter-do-update (reporter value &optional suffix) (let* ((parameters (cdr reporter)) (update-time (aref parameters 0)) (min-value (aref parameters 1)) @@ -5134,18 +5140,25 @@ progress-reporter-do-update (setcar reporter (ceiling (car reporter)))) ;; Only print message if enough time has passed (when enough-time-passed - (if (> percentage 0) - (message "%s%d%%" text percentage) - (message "%s" text))))) + (if suffix + (aset parameters 6 suffix) + (setq suffix (or (aref parameters 6) ""))) + (if (> percentage 0) + (message "%s%d%% %s" text percentage suffix) + (message "%s %s" text suffix))))) ;; Pulsing indicator (enough-time-passed - (let ((index (mod (1+ (car reporter)) 4)) - (message-log-max nil)) + (when (and value (not suffix)) + (setq suffix value)) + (if suffix + (aset parameters 6 suffix) + (setq suffix (or (aref parameters 6) ""))) + (let* ((index (mod (1+ (car reporter)) 4)) + (message-log-max nil) + (pulse-char (aref progress-reporter--pulse-characters + index))) (setcar reporter index) - (message "%s %s" - text - (aref progress-reporter--pulse-characters - index))))))) + (message "%s %s %s" text pulse-char suffix)))))) (defun progress-reporter-done (reporter) "Print reporter's message followed by word \"done\" in echo area." diff --git a/lisp/tar-mode.el b/lisp/tar-mode.el index c75fe7c373..26fa5e06b0 100644 --- a/lisp/tar-mode.el +++ b/lisp/tar-mode.el @@ -522,7 +522,8 @@ tar-untar-buffer "Extract all archive members in the tar-file into the current directory." (interactive) ;; FIXME: make it work even if we're not in tar-mode. - (let ((descriptors tar-parse-info)) ;Read the var in its buffer. + (let ((descriptors tar-parse-info) ;Read the var in its buffer. + (reporter (make-progress-reporter "Extracting"))) (with-current-buffer (if (tar-data-swapped-p) tar-data-buffer (current-buffer)) (set-buffer-multibyte nil) ;Hopefully, a no-op. @@ -535,17 +536,19 @@ tar-untar-buffer (start (tar-header-data-start descriptor)) (end (+ start (tar-header-size descriptor)))) (unless (file-directory-p name) - (message "Extracting %s" name) + (progress-reporter-update reporter name) (if (and dir (not (file-exists-p dir))) (make-directory dir t)) (unless (file-directory-p name) - (let ((coding-system-for-write 'no-conversion)) + (let ((coding-system-for-write 'no-conversion) + (write-region-inhibit-fsync t)) (when link-desc (lwarn '(tar link) :warning "Extracted `%s', %s, as a normal file" name link-desc)) - (write-region start end name))) - (set-file-modes name (tar-header-mode descriptor)))))))) + (write-region start end name nil :nomessage))) + (set-file-modes name (tar-header-mode descriptor))))) + (progress-reporter-done reporter)))) (defun tar-summarize-buffer () "Parse the contents of the tar file in the current buffer." -- 2.11.0 --=-=-=--