Received: (at 79546) by debbugs.gnu.org; 4 Nov 2025 12:24:32 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Tue Nov 04 07:24:32 2025 Received: from localhost ([127.0.0.1]:47220 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1vGG5P-0004i5-JM for submit <at> debbugs.gnu.org; Tue, 04 Nov 2025 07:24:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50138) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1vGG5M-0004he-Ai for 79546 <at> debbugs.gnu.org; Tue, 04 Nov 2025 07:24:30 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <eliz@HIDDEN>) id 1vGG5F-00021U-S1; Tue, 04 Nov 2025 07:24:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=aN2wrxp8UNSlnp2uIUJwjI1q7ThLMCgPqtpN7G7hgDI=; b=MoIfcSaBhE0c RAHPgWgharp7QDUvhINOL0Hdp4MLG8eNlhBBfRb4sxDTH7L40hVeGurpw7Q5GeCAdclcjNrMhknho vui/f16Jem4T2MsdOvvMC66kIkjqZz9AIphUX1SQ6c16kOIpBYxplbjp2iLPCGQzepCMb63pOZTxK 0w0FcsKEjhtbOUfQf1tPJ6Y2rth8fI1BPjDKDDZMh0fP0fZ9TYoL6DwEsDQ+X4nsOV5JYcZJ1IhJp i55C6ekq8zkPyLFMCuSFYjpXrBJkrcazmunS2JjPbild2WKRj4EP3a0+aaTxHw9hBvjQknGLejpHz +0EKWhP+7C2wlU8LMR+6jw==; Date: Tue, 04 Nov 2025 14:24:16 +0200 Message-Id: <86pl9yf0jz.fsf@HIDDEN> From: Eli Zaretskii <eliz@HIDDEN> To: Stefan Monnier <monnier@HIDDEN> In-Reply-To: <jwv8qgmy04e.fsf-monnier+emacs@HIDDEN> (message from Stefan Monnier on Mon, 03 Nov 2025 22:05:42 -0500) Subject: Re: bug#79546: 30.1; opening a diff file in diff-mode can be very slow References: <87ikgzxwlw.fsf@HIDDEN> <86a527f4fu.fsf@HIDDEN> <jwvecrdf01z.fsf-monnier+emacs@HIDDEN> <87ikfrrm2x.fsf@HIDDEN> <jwv1pmfyly6.fsf-monnier+emacs@HIDDEN> <87pl9zq6bt.fsf@HIDDEN> <jwv8qgmy04e.fsf-monnier+emacs@HIDDEN> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 79546 Cc: vincent@HIDDEN, 79546 <at> debbugs.gnu.org, spwhitton@HIDDEN X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > From: Stefan Monnier <monnier@HIDDEN> > Cc: Eli Zaretskii <eliz@HIDDEN>, 79546 <at> debbugs.gnu.org, Vincent Lefevre > <vincent@HIDDEN> > Date: Mon, 03 Nov 2025 22:05:42 -0500 > > Any comments/objections to the patch below? > > > diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el > index c6c6233485f..ec79e9fd249 100644 > --- a/lisp/vc/diff-mode.el > +++ b/lisp/vc/diff-mode.el > @@ -113,6 +113,16 @@ diff-refine > (const :tag "Refine hunks during font-lock" font-lock) > (const :tag "Refine hunks during navigation" navigation))) > > +(defcustom diff-refine-threshold 10000 > + ;; FIXME: A better way to handle this would be to do the refinement > + ;; asynchronously, so pathological cases just delay the refinement's display > + ;; but don't freeze Emacs. > + "Maximum size of diff hunk that can be automatically refined. > +If a hunk is larger than that limit, `diff-refine' is not automatically applied, > +to avoid pathological cases taking too long. > +Does not affect the `diff-refine-hunk' interactive command." > + :type 'integer) Please state in the doc string what units is this measured (characters? lines?).
bug-gnu-emacs@HIDDEN:bug#79546; Package emacs.
Full text available.
Received: (at 79546) by debbugs.gnu.org; 4 Nov 2025 03:06:03 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Nov 03 22:06:03 2025
Received: from localhost ([127.0.0.1]:45398 helo=debbugs.gnu.org)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
id 1vG7Mw-0001Xg-Ps
for submit <at> debbugs.gnu.org; Mon, 03 Nov 2025 22:06:03 -0500
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:8786)
by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
(Exim 4.84_2) (envelope-from <monnier@HIDDEN>)
id 1vG7Mu-0001XB-Eq
for 79546 <at> debbugs.gnu.org; Mon, 03 Nov 2025 22:06:00 -0500
Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1])
by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 8A46F8070E;
Mon, 3 Nov 2025 22:05:54 -0500 (EST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
s=mail; t=1762225549;
bh=mEHQZSmtZxuJ1OMuaFx2UMjJAdgHCWYrB32Jk1Ilgf0=;
h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
b=OTlyaYJEkgknpec4O1SWnm9L0NoOPFaMhyH5VRahF32ONd0gbfNbBxWwn6wsXXQbl
FeSjy4/gE9ExIqjs7fIA4SG3TiDY/ib0fBwzHiYDWgFNBYXvZ7b1qrY6/7zHOj3tX1
DLPYYqIIqTCmqUxpnRIk8WfTnExqFQ623BZoXV94ZKlJKKBSPs0tMAWh7TNEJ9FlqW
47Q4UlGoJCCbfcl8uVztI1AKmHPmlwabfSlFKbxm61OQZ91ajZLxTqD4b0s2IdRTQw
29IoJUZGTNfqpPgMS2MQyrkqrbJoVtAZEx/iYaOeiSfuLdfvrIQGJIzOJ2pFT6Y9J8
HRJ7rHGBspKCA==
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 3D42D80729;
Mon, 3 Nov 2025 22:05:49 -0500 (EST)
Received: from asado (unknown [181.28.45.30])
by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 932DB12041A;
Mon, 3 Nov 2025 22:05:47 -0500 (EST)
From: Stefan Monnier <monnier@HIDDEN>
To: Sean Whitton <spwhitton@HIDDEN>
Subject: Re: bug#79546: 30.1; opening a diff file in diff-mode can be very slow
In-Reply-To: <87pl9zq6bt.fsf@HIDDEN>
Message-ID: <jwv8qgmy04e.fsf-monnier+emacs@HIDDEN>
References: <87ikgzxwlw.fsf@HIDDEN> <86a527f4fu.fsf@HIDDEN>
<jwvecrdf01z.fsf-monnier+emacs@HIDDEN>
<87ikfrrm2x.fsf@HIDDEN>
<jwv1pmfyly6.fsf-monnier+emacs@HIDDEN>
<87pl9zq6bt.fsf@HIDDEN>
Date: Mon, 03 Nov 2025 22:05:42 -0500
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-SPAM-INFO: Spam detection results: 0
ALL_TRUSTED -1 Passed through trusted hosts only via SMTP
AWL -0.219 Adjusted score from AWL reputation of From: address
BAYES_00 -1.9 Bayes spam probability is 0 to 1%
DKIM_SIGNED 0.1 Message has a DKIM or DK signature,
not necessarily valid
DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
domain
DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from
domain
X-SPAM-LEVEL:
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 79546
Cc: Vincent Lefevre <vincent@HIDDEN>, Eli Zaretskii <eliz@HIDDEN>,
79546 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)
--=-=-=
Content-Type: text/plain
>> How 'bout skipping the refined-diff altogether when the to-be-refined
>> hunk is large?
> Yes, that seems fine to me.
Any comments/objections to the patch below?
Stefan
--=-=-=
Content-Type: text/x-diff
Content-Disposition: inline; filename=diff-refine.patch
diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el
index c6c6233485f..ec79e9fd249 100644
--- a/lisp/vc/diff-mode.el
+++ b/lisp/vc/diff-mode.el
@@ -113,6 +113,16 @@ diff-refine
(const :tag "Refine hunks during font-lock" font-lock)
(const :tag "Refine hunks during navigation" navigation)))
+(defcustom diff-refine-threshold 10000
+ ;; FIXME: A better way to handle this would be to do the refinement
+ ;; asynchronously, so pathological cases just delay the refinement's display
+ ;; but don't freeze Emacs.
+ "Maximum size of diff hunk that can be automatically refined.
+If a hunk is larger than that limit, `diff-refine' is not automatically applied,
+to avoid pathological cases taking too long.
+Does not affect the `diff-refine-hunk' interactive command."
+ :type 'integer)
+
(defcustom diff-font-lock-prettify nil
"If non-nil, font-lock will try and make the format prettier.
@@ -322,7 +332,8 @@ diff-minor-mode-map
(if diff-auto-refine-mode
(progn
(customize-set-variable 'diff-refine 'navigation)
- (condition-case-unless-debug nil (diff-refine-hunk) (error nil)))
+ (condition-case-unless-debug nil (diff-refine-hunk 'skip-if-large)
+ (error nil)))
(customize-set-variable 'diff-refine nil))))
(make-obsolete 'diff-auto-refine-mode "set `diff-refine' instead." "27.1")
(make-obsolete-variable 'diff-auto-refine-mode
@@ -805,7 +816,7 @@ diff--auto-refine-data
(with-current-buffer buffer
(save-excursion
(goto-char point)
- (diff-refine-hunk))))))))))))
+ (diff-refine-hunk 'skip-if-large))))))))))))
(easy-mmode-define-navigation
diff-file diff-file-header-re "file" diff-end-of-file)
@@ -2508,7 +2519,7 @@ diff--forward-while-leading-char
(setq pt (point)))
pt))
-(defun diff-refine-hunk ()
+(defun diff-refine-hunk (&optional skip-if-large)
"Highlight changes of hunk at point at a finer granularity."
(interactive)
(when (diff--some-hunks-p)
@@ -2517,7 +2528,7 @@ diff-refine-hunk
;; Be careful to start from the hunk header so diff-end-of-hunk
;; gets to read the hunk header's line info.
(end (progn (diff-end-of-hunk) (point))))
- (diff--refine-hunk beg end)))))
+ (diff--refine-hunk beg end skip-if-large)))))
(defun diff--refine-propertize (beg end face)
(let ((ol (make-overlay beg end)))
@@ -2537,7 +2548,7 @@ diff-refine-nonmodified
:version "30.1"
:type 'boolean)
-(defun diff--refine-hunk (start end)
+(defun diff--refine-hunk (start end &optional skip-if-large)
(require 'smerge-mode)
(goto-char start)
(let* ((style (diff-hunk-style)) ;Skips the hunk header as well.
@@ -2550,6 +2561,17 @@ diff--refine-hunk
(goto-char beg)
(pcase style
+ ((guard (and skip-if-large
+ ;; FIXME: Maybe instead of testing the hunk size, we
+ ;; should test the size of each individual "delete+insert"
+ ;; pairs, since a big hunk with many small del+ins pairs
+ ;; should not suffer from the usual pathological
+ ;; complexity problems.
+ ;; Or maybe even push the test down into
+ ;; `smerge-refine-regions' where `smerge-mode' could
+ ;; also use it?
+ (> (- end beg) diff-refine-threshold)))
+ nil)
('unified
(while (re-search-forward "^[-+]" end t)
(let ((beg-del (progn (beginning-of-line) (point)))
@@ -2669,7 +2691,7 @@ diff--font-lock-refined
max
(lambda (beg end)
(unless (get-char-property beg 'diff--font-lock-refined)
- (diff--refine-hunk beg end)
+ (diff--refine-hunk beg end 'skip-if-large)
(let ((ol (make-overlay beg end)))
(overlay-put ol 'diff--font-lock-refined t)
(overlay-put ol 'diff-mode 'fine)
--=-=-=--
bug-gnu-emacs@HIDDEN:bug#79546; Package emacs.
Full text available.Received: (at 79546) by debbugs.gnu.org; 3 Nov 2025 19:12:04 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Nov 03 14:12:04 2025 Received: from localhost ([127.0.0.1]:42819 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1vFzyG-0007SQ-26 for submit <at> debbugs.gnu.org; Mon, 03 Nov 2025 14:12:04 -0500 Received: from sendmail.purelymail.com ([34.202.193.197]:55976) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <spwhitton@HIDDEN>) id 1vFzyA-0007S1-Ak for 79546 <at> debbugs.gnu.org; Mon, 03 Nov 2025 14:11:59 -0500 DKIM-Signature: a=rsa-sha256; b=D3Yj+ZugyfMxq2z/grTjh22pcLUmFdoqiI5XomKaRpPAG6qKuNTzsu55oWRwIF1TbejVfZpWo2efmAWwYjqqBx1dG3Yn0VqIXPuOoFjocFE9RmDZEcubnaAaYEhlVKd8/bEtKmICxcOZsfswad3rlraeHwXWnBVjPz4eo6WK8G9LS+bHTye8aPE8TMwic/5kQRN3vnSv4UG2E9SDidZdfKSwjifQl39e13616Dg2+tddJVI2Qn9vCsTsnUGNE0Lx6IPTXXsKiqMve6uxJb5UQvNlkDc/TbBnA310RvMwuRQIkBonEEprW+PhlLPQgOEvcJFpJUVsghLjFCcaiHEmyQ==; s=purelymail1; d=spwhitton.name; v=1; bh=1r8unen/bTP1PCoaZuXfq0uSRO8/mh50UyfMFRLB9Pc=; h=Received:Received:From:To:Subject:Date; DKIM-Signature: a=rsa-sha256; b=fLVysSYpgCeRev7j2uk0r6JiXzdDw5j5HzAvHKlnUoVOglTlsKi2vUwbDTVYv4I2OhwEqzwlISTar1uKgWUSWxd+J1V+q/K1x59BHp3nvUcRDW30BbOa5s6KJR8lI7HGzixI1LXpgpZJA7+s4wKhD0Zpz79NeGbL05aVNpcm3jxXdHfOiR6XzjXksxZtorWsVrsQFB70XUyx502plhqnYprlHHHvawtZQgUCNjawKLQcSewDJuh6U8Koq+KwfX604udXnxr/p7viq0AkyMMjEb7NBiLBNymEZ4iEnxQ5/YTRC+Z5QHoJSxL/USlCt6gF3dPuq0wOrq+s2FX5xn7tSQ==; s=purelymail1; d=purelymail.com; v=1; bh=1r8unen/bTP1PCoaZuXfq0uSRO8/mh50UyfMFRLB9Pc=; h=Feedback-ID:Received:Received:From:To:Subject:Date; Feedback-ID: 20115:3760:null:purelymail X-Pm-Original-To: 79546 <at> debbugs.gnu.org Received: by smtp.purelymail.com (Purelymail SMTP) with ESMTPSA id -629249033; (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Mon, 03 Nov 2025 19:11:50 +0000 (UTC) Received: by zephyr.silentflame.com (Postfix, from userid 1000) id 41308942B4A; Mon, 03 Nov 2025 19:11:50 +0000 (GMT) From: Sean Whitton <spwhitton@HIDDEN> To: Stefan Monnier <monnier@HIDDEN> Subject: Re: bug#79546: 30.1; opening a diff file in diff-mode can be very slow In-Reply-To: <jwv1pmfyly6.fsf-monnier+emacs@HIDDEN> References: <87ikgzxwlw.fsf@HIDDEN> <86a527f4fu.fsf@HIDDEN> <jwvecrdf01z.fsf-monnier+emacs@HIDDEN> <87ikfrrm2x.fsf@HIDDEN> <jwv1pmfyly6.fsf-monnier+emacs@HIDDEN> Date: Mon, 03 Nov 2025 19:11:50 +0000 Message-ID: <87pl9zq6bt.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 79546 Cc: Vincent Lefevre <vincent@HIDDEN>, Eli Zaretskii <eliz@HIDDEN>, 79546 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Hello, On Mon 03 Nov 2025 at 02:08pm -05, Stefan Monnier wrote: >> Well, for now, how about putting something in to skip -d in the case of >> a large file? Seems worth the targeted optimisation, to me. > > How 'bout skipping the refined-diff altogether when the to-be-refined > hunk is large? Yes, that seems fine to me. -- Sean Whitton
bug-gnu-emacs@HIDDEN:bug#79546; Package emacs.
Full text available.
Received: (at 79546) by debbugs.gnu.org; 3 Nov 2025 19:08:29 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Nov 03 14:08:29 2025
Received: from localhost ([127.0.0.1]:42789 helo=debbugs.gnu.org)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
id 1vFzul-0007K3-2d
for submit <at> debbugs.gnu.org; Mon, 03 Nov 2025 14:08:29 -0500
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:12755)
by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
(Exim 4.84_2) (envelope-from <monnier@HIDDEN>)
id 1vFzug-0007Jv-BT
for 79546 <at> debbugs.gnu.org; Mon, 03 Nov 2025 14:08:23 -0500
Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1])
by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 346D98168B;
Mon, 3 Nov 2025 14:08:16 -0500 (EST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
s=mail; t=1762196895;
bh=a+VSH9hZueL3j8T7L07tD2kH8YLlbjd/CHwClKfCt8I=;
h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
b=buOh43kqCCPmD0n7bkjSk8Bm3DRAI25FStYsl3NruxWoLokb7bf6xkf6eejCUOnkL
GiFjLmMtcLQCw0/24Y3fg94TYovHgxu035bJQD0WaNw414rD8HwKi34bCwkE1cmVnC
/C0jTnnGv1n+O3/oYdHIyFzeQTVMkYIy3X4hOMEkkfq42TRremkqcfXgYP13Pxljft
bE6yRzDwVB2xu/tk06Q2f7GoX29x5HnbXrmgwX9BzZoUxR2Wb7Ezzpu96DnrbF6t8E
cKebRx0hBYfEiKivBgEbrNrtlB3C9DAvXO1j4zKGND+5j+ZIhflS645rFzGsdxPXHh
N0cSmanIt5hHQ==
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 4FBBB807F3;
Mon, 3 Nov 2025 14:08:15 -0500 (EST)
Received: from asado (unknown [181.29.41.154])
by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 3AD41120630;
Mon, 3 Nov 2025 14:08:12 -0500 (EST)
From: Stefan Monnier <monnier@HIDDEN>
To: Sean Whitton <spwhitton@HIDDEN>
Subject: Re: bug#79546: 30.1; opening a diff file in diff-mode can be very slow
In-Reply-To: <87ikfrrm2x.fsf@HIDDEN>
Message-ID: <jwv1pmfyly6.fsf-monnier+emacs@HIDDEN>
References: <87ikgzxwlw.fsf@HIDDEN> <86a527f4fu.fsf@HIDDEN>
<jwvecrdf01z.fsf-monnier+emacs@HIDDEN>
<87ikfrrm2x.fsf@HIDDEN>
Date: Mon, 03 Nov 2025 14:08:09 -0500
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-SPAM-INFO: Spam detection results: 0
ALL_TRUSTED -1 Passed through trusted hosts only via SMTP
BAYES_00 -1.9 Bayes spam probability is 0 to 1%
DKIM_SIGNED 0.1 Message has a DKIM or DK signature,
not necessarily valid
DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
domain
DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from
domain
X-SPAM-LEVEL:
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 79546
Cc: Vincent Lefevre <vincent@HIDDEN>, Eli Zaretskii <eliz@HIDDEN>,
79546 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)
> Well, for now, how about putting something in to skip -d in the case of
> a large file? Seems worth the targeted optimisation, to me.
How 'bout skipping the refined-diff altogether when the to-be-refined
hunk is large?
Stefan
bug-gnu-emacs@HIDDEN:bug#79546; Package emacs.
Full text available.Received: (at 79546) by debbugs.gnu.org; 3 Nov 2025 18:46:27 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Nov 03 13:46:27 2025 Received: from localhost ([127.0.0.1]:42672 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1vFzZT-0006dd-0j for submit <at> debbugs.gnu.org; Mon, 03 Nov 2025 13:46:27 -0500 Received: from sendmail.purelymail.com ([34.202.193.197]:51544) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <spwhitton@HIDDEN>) id 1vFzZO-0006dQ-Rt for 79546 <at> debbugs.gnu.org; Mon, 03 Nov 2025 13:46:23 -0500 DKIM-Signature: a=rsa-sha256; b=pCvL4VAQXttjpztqMyhY1y7T3Jovu+aeP1fhvnff1VZ5vJ4JW8T8W6rnC1qsVoj/KVOECeoki8h9cDPvVpbEIp+oZP8+t3ah41s5rEKLSYeoLi9p9EZLoA9yO5cYQ5BwJHqzOsGtfIzw8FCS9wmI4IxjLlZI7onWf/m0SNvVcgxVDTdggSQ3fqwb3TynA8TxMvz6y7l/nxHoqAOwgkqTtyColh+BM7vd+DJPPpPFLVMc//7oCrO4F2Yog05aURz6Fy2u5qd84/8Av06iw6BeeenDkdVdPlIRzHAmuvwu3zOxXNCMhrdJaszA31HTEqXgDnZLIBJE74efIpGpIAHkFw==; s=purelymail1; d=spwhitton.name; v=1; bh=hdH+S3/V+1cCnSovXg0RDqcFjya984cRc1pbL3x13GY=; h=Received:Received:From:To:Subject:Date; DKIM-Signature: a=rsa-sha256; b=p475CJrr6lnqTgn1+X/qV2lG2U4u40vf1YVYmFIY4qHfGcTy0Iu6mbHTBaSuAutXs0tfhLs+bWiqnvLa6WOy8yvbSQQHQQbtjg7QIO8Oo8uwXssvQigZpwlJXhhWhdBXNNSkgOfcrg7Ee+Qg6lvmrJM3SayC/ICxmOXi1xWSapsuKSXXqzGo1W8VL1CcUJ8AmJtr4OwrBisbOg8rEoSkzhkIFVfJulhBmUXVLxvgp1zceMjZI3AaQm5VDuFqqZOcHcIodcgk+CWCAlB2gV5X8D36LwqSGHsyDTHvf+hPpOlfeLde685DaczVCiJc7J16PbPpDSnglnqnNLfY60rOig==; s=purelymail1; d=purelymail.com; v=1; bh=hdH+S3/V+1cCnSovXg0RDqcFjya984cRc1pbL3x13GY=; h=Feedback-ID:Received:Received:From:To:Subject:Date; Feedback-ID: 20115:3760:null:purelymail X-Pm-Original-To: 79546 <at> debbugs.gnu.org Received: by smtp.purelymail.com (Purelymail SMTP) with ESMTPSA id 1295184329; (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Mon, 03 Nov 2025 18:46:15 +0000 (UTC) Received: by zephyr.silentflame.com (Postfix, from userid 1000) id 9D111942B4A; Mon, 03 Nov 2025 18:46:14 +0000 (GMT) From: Sean Whitton <spwhitton@HIDDEN> To: Eli Zaretskii <eliz@HIDDEN>, Stefan Monnier <monnier@HIDDEN>, 79546 <at> debbugs.gnu.org, Vincent Lefevre <vincent@HIDDEN> Subject: Re: bug#79546: 30.1; opening a diff file in diff-mode can be very slow In-Reply-To: <jwvecrdf01z.fsf-monnier+emacs@HIDDEN> References: <87ikgzxwlw.fsf@HIDDEN> <86a527f4fu.fsf@HIDDEN> <jwvecrdf01z.fsf-monnier+emacs@HIDDEN> Date: Mon, 03 Nov 2025 18:46:14 +0000 Message-ID: <87ikfrrm2x.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 79546 X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Hello, On Wed 08 Oct 2025 at 07:37pm -04, Stefan Monnier wrote: >>> $ echo . > file1 >>> $ seq 50000 > file2 >>> $ diff -u file1 file2 > file.diff >>> $ emacs -Q file.diff >>> >>> takes 17 seconds on my machine. With 100000 instead of 50000, >>> this takes 72 seconds, i.e. about 4 times as much. >>> >>> This is due to the use of the -d diff option. This option is fine >>> most of the time, but with some diff files like the above one, it >>> is unusable. Perhaps there should be some limit above which this >>> option should not be used. Ideally, I think that such a limit >>> should be detected in the diff utility for the algorithm selection; >>> otherwise Emacs might have to drop the -d option even when this is >>> not needed. > > Largely agreed. >> >> Stefan, any comments or suggestions? > > There are several problems, actually in this area of the code. > > Trying to avoid "pathologically" slow behavior in `diff` might be worth > pursuing, but it won't fix all cases anyway, so on Emacs's side the > more important issue is to make the `diff-font-lock-refined` > feature asynchronous. Well, for now, how about putting something in to skip -d in the case of a large file? Seems worth the targeted optimisation, to me. -- Sean Whitton
bug-gnu-emacs@HIDDEN:bug#79546; Package emacs.
Full text available.
Received: (at 79546) by debbugs.gnu.org; 8 Oct 2025 23:37:21 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Oct 08 19:37:21 2025
Received: from localhost ([127.0.0.1]:34916 helo=debbugs.gnu.org)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
id 1v6dii-0003Mb-Rt
for submit <at> debbugs.gnu.org; Wed, 08 Oct 2025 19:37:21 -0400
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:64430)
by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
(Exim 4.84_2) (envelope-from <monnier@HIDDEN>)
id 1v6dic-0003M3-5f
for 79546 <at> debbugs.gnu.org; Wed, 08 Oct 2025 19:37:17 -0400
Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1])
by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 632BC10024D;
Wed, 8 Oct 2025 19:37:08 -0400 (EDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
s=mail; t=1759966627;
bh=ImJoaDpzsxpi5v2/XyDI7taUxfCQaxks4dD2zcxAzOk=;
h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
b=eARRMaB3vZy43W0ZKoXuA7jo5EuEt4kpMIRwB5ZvXJuzRUDb3wRkb5Hg0G+KhmwiG
KPEdD2JH4cGFCYfQq76wiTAWBUJbdqfWhEnkxE+y2iE+yDTDLVM1NRxmA0Z+aURVO+
sDvK41GLOFDLNQk9NIx3uFhYSZWLf3C8uaXUBNhmxEGOD78wwYhHhvMsPLsknEdyLK
RtC5tQz59ZuSswS3ZcfSsWhbe8l9qW519Gu4oS7YreGtdbLC4UpYk0TWuhl9EOEN2t
yk7YRIq5c20PJTYhKM/W1NegJBG/MNGTzvfwj1cBFGLWRSOFQl3sebFn+rsGKg28ly
y/0HahfA1rqgA==
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 34243100034;
Wed, 8 Oct 2025 19:37:07 -0400 (EDT)
Received: from asado (unknown [181.28.45.30])
by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id E9B6512068A;
Wed, 8 Oct 2025 19:37:05 -0400 (EDT)
From: Stefan Monnier <monnier@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#79546: 30.1; opening a diff file in diff-mode can be very slow
In-Reply-To: <86a527f4fu.fsf@HIDDEN>
Message-ID: <jwvecrdf01z.fsf-monnier+emacs@HIDDEN>
References: <87ikgzxwlw.fsf@HIDDEN> <86a527f4fu.fsf@HIDDEN>
Date: Wed, 08 Oct 2025 19:37:02 -0400
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-SPAM-INFO: Spam detection results: 0
ALL_TRUSTED -1 Passed through trusted hosts only via SMTP
AWL 0.031 Adjusted score from AWL reputation of From: address
BAYES_00 -1.9 Bayes spam probability is 0 to 1%
DKIM_SIGNED 0.1 Message has a DKIM or DK signature,
not necessarily valid
DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
domain
DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from
domain
X-SPAM-LEVEL:
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 79546
Cc: 79546 <at> debbugs.gnu.org, Vincent Lefevre <vincent@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)
>> $ echo . > file1
>> $ seq 50000 > file2
>> $ diff -u file1 file2 > file.diff
>> $ emacs -Q file.diff
>>
>> takes 17 seconds on my machine. With 100000 instead of 50000,
>> this takes 72 seconds, i.e. about 4 times as much.
>>
>> This is due to the use of the -d diff option. This option is fine
>> most of the time, but with some diff files like the above one, it
>> is unusable. Perhaps there should be some limit above which this
>> option should not be used. Ideally, I think that such a limit
>> should be detected in the diff utility for the algorithm selection;
>> otherwise Emacs might have to drop the -d option even when this is
>> not needed.
Largely agreed.
>> The related bug in diffutils I had reported last year:
>>
>> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=72723
>>
>> There I had mentioned that in lisp/vc/smerge-mode.el:
>>
>> (let ((coding-system-for-read 'utf-8-emacs))
>> (call-process diff-command nil t nil
>> (if (and smerge-refine-ignore-whitespace
>> (not smerge-refine-weight-hack))
>> ;; Pass -a so diff treats it as a text file even
>> ;; if it contains \0 and such.
>> ;; Pass -d so as to get the smallest change, but
>> ;; also and more importantly because otherwise it
>> ;; may happen that diff doesn't behave like
>> ;; smerge-refine-weight-hack expects it to.
>> ;; See https://lists.gnu.org/r/emacs-devel/2007-11/msg00401.html
>> "-awd" "-ad")
>> file1 file2))
>>
>> I suppose that this is the code that is called, as I couldn't
>> find another occurrence of -ad. So there is a reference to
Yup. FWIW, I never really figured out what was the problem that
appeared when not using `-d`. Using `-d` was more of a workaround than
an actual fix.
[ I have a vague recollection that `smerge-refine-weight-hack` assumes
that when it puts N copies of a line in one of the two inputs, it
expects those N lines to be together (or absent) in the output. ]
>> https://lists.gnu.org/r/emacs-devel/2007-11/msg00401.html
>>
>> (that was with diff (GNU diffutils) 2.8.1) and the latest message
>> (about the use of -d, in particular):
>>
>> https://lists.gnu.org/r/emacs-devel/2007-11/msg00522.html
>
> Stefan, any comments or suggestions?
There are several problems, actually in this area of the code.
Trying to avoid "pathologically" slow behavior in `diff` might be worth
pursuing, but it won't fix all cases anyway, so on Emacs's side the
more important issue is to make the `diff-font-lock-refined`
feature asynchronous.
Stefan
bug-gnu-emacs@HIDDEN:bug#79546; Package emacs.
Full text available.Received: (at 79546) by debbugs.gnu.org; 4 Oct 2025 08:37:39 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sat Oct 04 04:37:39 2025 Received: from localhost ([127.0.0.1]:47809 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1v4xlq-0006uC-KF for submit <at> debbugs.gnu.org; Sat, 04 Oct 2025 04:37:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33932) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1v4xln-0006ty-UO for 79546 <at> debbugs.gnu.org; Sat, 04 Oct 2025 04:37:36 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <eliz@HIDDEN>) id 1v4xlh-0007wO-FG; Sat, 04 Oct 2025 04:37:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=geCJNK2INvzpisQes1mLydOO+lA4T8BwUf87PgDWX2Q=; b=IWhNHAe0EZ/S XdHgOYphjbVziOGgkoEdCnhXTwRYChQIymOQNM4nAiPSOQFPKcs+jD9tHS4/GwWg1aMwUKrXJxW86 TNELJ0QLXjGJ0K4AHGPfKAjUz9ZaCDTloopfqgzpl1J96YUykooJNwJWJZ0MKoq+BCLxu/c14/xga C9V2X/queAUUgTzW9AzCEdAtVmOHu57DnrYUaTwxZO2cypxiv5UPmd0FSzkKo91SJi+XvQonbSb+x MclgWi6T6PzIC+v8d2weZkwrWYfwem9rrscSJBwbBi2RXcAvO0GuYaimTwLLRFDw3p7vZQU3RjHSf WhoZdcsDaE5UvqEKeVxh7Q==; Date: Sat, 04 Oct 2025 11:37:25 +0300 Message-Id: <86a527f4fu.fsf@HIDDEN> From: Eli Zaretskii <eliz@HIDDEN> To: Vincent Lefevre <vincent@HIDDEN>, Stefan Monnier <monnier@HIDDEN> In-Reply-To: <87ikgzxwlw.fsf@HIDDEN> (message from Vincent Lefevre on Wed, 01 Oct 2025 03:02:35 +0200) Subject: Re: bug#79546: 30.1; opening a diff file in diff-mode can be very slow References: <87ikgzxwlw.fsf@HIDDEN> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 79546 Cc: 79546 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > From: Vincent Lefevre <vincent@HIDDEN> > Date: Wed, 01 Oct 2025 03:02:35 +0200 > > > $ echo . > file1 > $ seq 50000 > file2 > $ diff -u file1 file2 > file.diff > $ emacs -Q file.diff > > takes 17 seconds on my machine. With 100000 instead of 50000, > this takes 72 seconds, i.e. about 4 times as much. > > This is due to the use of the -d diff option. This option is fine > most of the time, but with some diff files like the above one, it > is unusable. Perhaps there should be some limit about which this > option should not be used. Ideally, I think that such a limit > should be detected in the diff utility for the algorithm selection; > otherwise Emacs might have to drop the -d option even when this is > not needed. > > The related bug in diffutils I had reported last year: > > https://debbugs.gnu.org/cgi/bugreport.cgi?bug=72723 > > There I had mentioned that in lisp/vc/smerge-mode.el: > > (let ((coding-system-for-read 'utf-8-emacs)) > (call-process diff-command nil t nil > (if (and smerge-refine-ignore-whitespace > (not smerge-refine-weight-hack)) > ;; Pass -a so diff treats it as a text file even > ;; if it contains \0 and such. > ;; Pass -d so as to get the smallest change, but > ;; also and more importantly because otherwise it > ;; may happen that diff doesn't behave like > ;; smerge-refine-weight-hack expects it to. > ;; See https://lists.gnu.org/r/emacs-devel/2007-11/msg00401.html > "-awd" "-ad") > file1 file2)) > > I suppose that this is the code that is called, as I couldn't > find another occurrence of -ad. So there is a reference to > > https://lists.gnu.org/r/emacs-devel/2007-11/msg00401.html > > (that was with diff (GNU diffutils) 2.8.1) and the latest message > (about the use of -d, in particular): > > https://lists.gnu.org/r/emacs-devel/2007-11/msg00522.html Stefan, any comments or suggestions?
bug-gnu-emacs@HIDDEN:bug#79546; Package emacs.
Full text available.
Received: (at submit) by debbugs.gnu.org; 1 Oct 2025 01:04:22 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Sep 30 21:04:22 2025
Received: from localhost ([127.0.0.1]:33062 helo=debbugs.gnu.org)
by debbugs.gnu.org with esmtp (Exim 4.84_2)
(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
id 1v3lGU-0004CL-Kc
for submit <at> debbugs.gnu.org; Tue, 30 Sep 2025 21:04:22 -0400
Received: from lists.gnu.org ([2001:470:142::17]:37032)
by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
(Exim 4.84_2) (envelope-from <vincent@HIDDEN>)
id 1v3lGD-0004BM-NQ
for submit <at> debbugs.gnu.org; Tue, 30 Sep 2025 21:04:07 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10])
by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
(Exim 4.90_1) (envelope-from <vincent@HIDDEN>)
id 1v3lFt-0005S5-7L
for bug-gnu-emacs@HIDDEN; Tue, 30 Sep 2025 21:03:43 -0400
Received: from joooj.vinc17.net ([155.133.131.76])
by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
(Exim 4.90_1) (envelope-from <vincent@HIDDEN>)
id 1v3lFB-00083k-9W
for bug-gnu-emacs@HIDDEN; Tue, 30 Sep 2025 21:03:37 -0400
Received: from smtp-qaa.vinc17.net (135.197.67.86.rev.sfr.net [86.67.197.135])
by joooj.vinc17.net (Postfix) with ESMTPSA id 4CA1B15E;
Wed, 1 Oct 2025 03:02:36 +0200 (CEST)
Received: by qaa.vinc17.org (Postfix, from userid 1000)
id 07B17CA0180; Wed, 01 Oct 2025 03:02:36 +0200 (CEST)
From: Vincent Lefevre <vincent@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 30.1; opening a diff file in diff-mode can be very slow
X-Debbugs-Cc:
Date: Wed, 01 Oct 2025 03:02:35 +0200
Message-ID: <87ikgzxwlw.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
Received-SPF: pass client-ip=155.133.131.76; envelope-from=vincent@HIDDEN;
helo=joooj.vinc17.net
X-Spam_score_int: -18
X-Spam_score: -1.9
X-Spam_bar: -
X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9,
RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001,
SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)
$ echo . > file1
$ seq 50000 > file2
$ diff -u file1 file2 > file.diff
$ emacs -Q file.diff
takes 17 seconds on my machine. With 100000 instead of 50000,
this takes 72 seconds, i.e. about 4 times as much.
This is due to the use of the -d diff option. This option is fine
most of the time, but with some diff files like the above one, it
is unusable. Perhaps there should be some limit about which this
option should not be used. Ideally, I think that such a limit
should be detected in the diff utility for the algorithm selection;
otherwise Emacs might have to drop the -d option even when this is
not needed.
The related bug in diffutils I had reported last year:
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=72723
There I had mentioned that in lisp/vc/smerge-mode.el:
(let ((coding-system-for-read 'utf-8-emacs))
(call-process diff-command nil t nil
(if (and smerge-refine-ignore-whitespace
(not smerge-refine-weight-hack))
;; Pass -a so diff treats it as a text file even
;; if it contains \0 and such.
;; Pass -d so as to get the smallest change, but
;; also and more importantly because otherwise it
;; may happen that diff doesn't behave like
;; smerge-refine-weight-hack expects it to.
;; See https://lists.gnu.org/r/emacs-devel/2007-11/msg00401.html
"-awd" "-ad")
file1 file2))
I suppose that this is the code that is called, as I couldn't
find another occurrence of -ad. So there is a reference to
https://lists.gnu.org/r/emacs-devel/2007-11/msg00401.html
(that was with diff (GNU diffutils) 2.8.1) and the latest message
(about the use of -d, in particular):
https://lists.gnu.org/r/emacs-devel/2007-11/msg00522.html
In GNU Emacs 30.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.50,
cairo version 1.18.4) of 2025-08-26, modified by Debian built on sbuild
Windowing system distributor 'The X.Org Foundation', version 11.0.12101018
System Description: Debian GNU/Linux forky/sid
Configured using:
'configure --build x86_64-linux-gnu --prefix=/usr
--sharedstatedir=/var/lib --libexecdir=/usr/libexec
--localstatedir=/var/lib --infodir=/usr/share/info
--mandir=/usr/share/man --with-libsystemd --with-pop=yes
--enable-locallisppath=/etc/emacs:/usr/local/share/emacs/30.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/30.1/site-lisp:/usr/share/emacs/site-lisp
--with-sound=alsa --without-gconf --with-mailutils --build
x86_64-linux-gnu --prefix=/usr --sharedstatedir=/var/lib
--libexecdir=/usr/libexec --localstatedir=/var/lib
--infodir=/usr/share/info --mandir=/usr/share/man --with-libsystemd
--with-pop=yes
--enable-locallisppath=/etc/emacs:/usr/local/share/emacs/30.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/30.1/site-lisp:/usr/share/emacs/site-lisp
--with-sound=alsa --without-gconf --with-mailutils --with-cairo
--with-x=yes --with-x-toolkit=gtk3 --with-toolkit-scroll-bars
'CFLAGS=-g -O2 -Werror=implicit-function-declaration
-ffile-prefix-map=/build/reproducible-path/emacs-30.1+1=.
-fstack-protector-strong -fstack-clash-protection -Wformat
-Werror=format-security -fcf-protection -Wall' 'CPPFLAGS=-Wdate-time
-D_FORTIFY_SOURCE=2' LDFLAGS=-Wl,-z,relro'
Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NATIVE_COMP
NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB
Important settings:
value of $LC_COLLATE: POSIX
value of $LC_CTYPE: C.UTF-8
value of $LC_TIME: en_DK.utf8
value of $LANG: C.UTF-8
locale-coding-system: utf-8-unix
Major mode: Lisp Interaction
Minor modes in effect:
display-time-mode: t
tooltip-mode: t
global-eldoc-mode: t
eldoc-mode: t
show-paren-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
minibuffer-regexp-mode: t
column-number-mode: t
line-number-mode: t
transient-mark-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
Load-path shadows:
/usr/share/emacs/site-lisp/llvm-13/llvm-mode hides /usr/share/emacs/site-lisp/llvm-14/llvm-mode
/usr/share/emacs/site-lisp/llvm-13/tablegen-mode hides /usr/share/emacs/site-lisp/llvm-14/tablegen-mode
/usr/share/emacs/site-lisp/llvm-13/emacs hides /usr/share/emacs/site-lisp/llvm-14/emacs
/usr/share/emacs/site-lisp/llvm-13/llvm-mode hides /usr/share/emacs/site-lisp/llvm-15/llvm-mode
/usr/share/emacs/site-lisp/llvm-13/tablegen-mode hides /usr/share/emacs/site-lisp/llvm-15/tablegen-mode
/usr/share/emacs/site-lisp/llvm-13/emacs hides /usr/share/emacs/site-lisp/llvm-15/emacs
/usr/share/emacs/site-lisp/llvm-13/llvm-mode hides /usr/share/emacs/site-lisp/llvm-16/llvm-mode
/usr/share/emacs/site-lisp/llvm-13/tablegen-mode hides /usr/share/emacs/site-lisp/llvm-16/tablegen-mode
/usr/share/emacs/site-lisp/llvm-13/emacs hides /usr/share/emacs/site-lisp/llvm-16/emacs
/usr/share/emacs/site-lisp/llvm-13/llvm-mode hides /usr/share/emacs/site-lisp/llvm-17/llvm-mode
/usr/share/emacs/site-lisp/llvm-13/tablegen-mode hides /usr/share/emacs/site-lisp/llvm-17/tablegen-mode
/usr/share/emacs/site-lisp/llvm-13/emacs hides /usr/share/emacs/site-lisp/llvm-17/emacs
/usr/share/emacs/site-lisp/llvm-13/llvm-mode hides /usr/share/emacs/site-lisp/llvm-18/llvm-mode
/usr/share/emacs/site-lisp/llvm-13/tablegen-mode hides /usr/share/emacs/site-lisp/llvm-18/tablegen-mode
/usr/share/emacs/site-lisp/llvm-13/emacs hides /usr/share/emacs/site-lisp/llvm-18/emacs
/usr/share/emacs/site-lisp/llvm-13/llvm-mode hides /usr/share/emacs/site-lisp/llvm-19/llvm-mode
/usr/share/emacs/site-lisp/llvm-13/tablegen-mode hides /usr/share/emacs/site-lisp/llvm-19/tablegen-mode
/usr/share/emacs/site-lisp/llvm-13/emacs hides /usr/share/emacs/site-lisp/llvm-19/emacs
/usr/share/emacs/site-lisp/elpa/po-mode-0.23.1/po-mode-autoloads hides /usr/share/emacs/site-lisp/elpa-src/po-mode-0.23.1/po-mode-autoloads
/usr/share/emacs/site-lisp/elpa/po-mode-0.23.1/po-mode hides /usr/share/emacs/site-lisp/elpa-src/po-mode-0.23.1/po-mode
/usr/share/emacs/site-lisp/elpa/po-mode-0.23.1/po-mode-pkg hides /usr/share/emacs/site-lisp/elpa-src/po-mode-0.23.1/po-mode-pkg
/usr/share/emacs/site-lisp/flim/sasl hides /usr/share/emacs/30.1/lisp/net/sasl
/usr/share/emacs/site-lisp/latex-cjk-thai/thai-word hides /usr/share/emacs/30.1/lisp/language/thai-word
Features:
(shadow sort mail-extr cl-extra help-mode warnings compile comint
ansi-osc ansi-color ring comp-run comp-common rx emacsbug message
yank-media puny dired dired-loaddefs rfc822 mml mml-sec epa derived epg
rfc6068 epg-config gnus-util text-property-search time-date mm-decode
mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader
sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils
cus-start time cc-styles cc-align cc-engine cc-vars cc-defs w3m-load
mmm-auto mmm-vars mmm-utils mmm-compat cus-edit pp cus-load wid-edit
po-mode-autoloads package browse-url url url-proxy url-privacy
url-expand url-methods url-history url-cookie generate-lisp-file
url-domsuf url-util mailcap url-handlers url-parse auth-source cl-seq
eieio eieio-core cl-macs icons password-cache json subr-x map byte-opt
gv bytecomp byte-compile url-vars cl-loaddefs cl-lib rmc iso-transl
tooltip cconv eldoc paren electric uniquify ediff-hook vc-hooks
lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win x-dnd
touch-screen tool-bar dnd fontset image regexp-opt fringe tabulated-list
replace newcomment text-mode lisp-mode prog-mode register page tab-bar
menu-bar rfn-eshadow isearch easymenu timer select scroll-bar mouse
jit-lock font-lock syntax font-core term/tty-colors frame minibuffer
nadvice seq simple cl-generic indonesian philippine cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese composite emoji-zwj charscript charprop
case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure
cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp
files window text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget keymap hashtable-print-readable backquote
threads dbusbind inotify lcms2 dynamic-setting system-font-setting
font-render-setting cairo gtk x-toolkit xinput2 x multi-tty move-toolbar
make-network-process native-compile emacs)
Memory information:
((conses 16 151408 12358) (symbols 48 11934 0) (strings 32 36620 3835)
(string-bytes 1 1200727) (vectors 16 18965)
(vector-slots 8 477214 75973) (floats 8 54 6) (intervals 56 375 0)
(buffers 992 12))
--
Vincent Lefevre <vincent@HIDDEN>:bug-gnu-emacs@HIDDEN.
Full text available.bug-gnu-emacs@HIDDEN:bug#79546; Package emacs.
Full text available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.