From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.devel Subject: Re: Change in vc-git ls-files-unknown makes emacs hang Date: Fri, 20 Dec 2019 16:13:59 +0200 Message-ID: <3df8e670-91f7-0f56-927d-8c2063b33fe1@yandex.ru> References: <08cfaf0c-215f-1b02-37f8-2b3886a319c7@yandex.ru> <3ffa93fe-06af-2920-812c-4a67367f2933@yandex.ru> <83fthf1mff.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------77B04CEE07377C4B7C735273" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="33753"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 To: Eli Zaretskii , emacs-devel@gnu.org, andreyk.mad@gmail.com, monnier@iro.umontreal.ca Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Dec 20 15:33:38 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iiJLV-0008c5-Qm for ged-emacs-devel@m.gmane.org; Fri, 20 Dec 2019 15:33:37 +0100 Original-Received: from localhost ([::1]:57224 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iiJLT-0005f8-Sw for ged-emacs-devel@m.gmane.org; Fri, 20 Dec 2019 09:33:35 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53777) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iiJ2b-0003FS-RP for emacs-devel@gnu.org; Fri, 20 Dec 2019 09:14:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iiJ2a-0005QT-EW for emacs-devel@gnu.org; Fri, 20 Dec 2019 09:14:05 -0500 Original-Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:55411) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iiJ2a-0005LQ-0T; Fri, 20 Dec 2019 09:14:04 -0500 Original-Received: by mail-wm1-x344.google.com with SMTP id q9so9096711wmj.5; Fri, 20 Dec 2019 06:14:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=u1ruoTdbweRcYkPlvNwlpCY0n4aMpH5hMYuOIv080vg=; b=I9BiOFpwv01cbr0dHvwnWpa+k3lI2wJBy4RidI01U4MIx9x3MT3fEwKAJgdooRW92z BIfBpVxH9pqiuryphtwbVBxNG038UOLtsTe2BBpvE2JKt2YAHPK2xPEt6aFiOmusnjVe lPQxwPUbvQRLzQ4useqIq7wWy2emrRr8jnhuIgm7DlE4ddVeH1X5fFIy46IQuXyKjdTl l7FL5CAj0Z2LwRnt7xM/Fs/G8Lyr/+0EOc+k4d1fMxsfM44nslqCIF/KoM7Zk0pkzXLA txAkRdFe4v9frl6NFAu+hK124QGFFT34AczA91n4JZZuWmwL9T7n7uS+EAuk58YAOS/3 r0ZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language; bh=u1ruoTdbweRcYkPlvNwlpCY0n4aMpH5hMYuOIv080vg=; b=MPGLvu4MBqFRWh8e+lQVuKzwJFjFOJzDO0o/A5wt0BWSct2uynC0gtE1SREBVrGooB 9idkvZALgvZc9/X9SYso1mSgzTO2C+xFA+AfvvTMR+L/WfkysVacNWcFOq/I+pU2aWOG H0oMwj5rrw+tF2jL7QmP2UxRJ4xubZCB6K+goX7td5s1u6P+weE1BnBUkjp+KRw+UiFR /EfL1p3j+48IqO2N84INLHG9bu6NjLYcX0qtD7+DWs8OofnT06ummzJhWoq31snCogIG jDZrsfQhdgoALJf/1v49/VsaNZb8hHX//wtLWyxQoDHBowNynh74vskNlwEeJBp5ieWE 09ow== X-Gm-Message-State: APjAAAU8eLxzM7EahE5kf4GUnS4F5rfZMSLzt7SbX+6LIawCjiW1mzem m+rYwTIZe9JWI6B+R3AouaM= X-Google-Smtp-Source: APXvYqxLS6NVVMp98YuPVK0jEG58zxKSaZkSJPMKWJCTkLGU3AJd7kXPXK1ATb5YoBKj+PCL2J+HRQ== X-Received: by 2002:a1c:9d81:: with SMTP id g123mr16684067wme.29.1576851242846; Fri, 20 Dec 2019 06:14:02 -0800 (PST) Original-Received: from [192.168.0.149] ([109.110.245.170]) by smtp.googlemail.com with ESMTPSA id h66sm10977418wme.41.2019.12.20.06.14.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Dec 2019 06:14:01 -0800 (PST) In-Reply-To: Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::344 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.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:243506 Archived-At: This is a multi-part message in MIME format. --------------77B04CEE07377C4B7C735273 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 20.12.2019 12:52, Filipp Gunbin wrote: >> Filipp, please produce a backtrace during the freeze, either by using >> SIGUSR2, as Stefan suggested, or by attaching a debugger, and post the >> backtrace. > > Hi, please find the trace in the attach (it's large). Thank you. It doesn't exactly answer my question about desktop-read (did you really have an old VC-Dir buffer in that saved session?), but it shows one bottleneck. One that is even prominently decorated with an old comment saying "this is VERY inefficient". :-) Here's a patch you can try. It should help to an extent. And if it's the main bottleneck, we can optimize further, e.g. by eliminating the expand-file-name calls. But if in the end you should see one very long VC-Dir buffer, which can be a usability problem on its own. --------------77B04CEE07377C4B7C735273 Content-Type: text/x-patch; name="vc-dir-update-faster.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="vc-dir-update-faster.diff" diff --git a/lisp/vc/vc-dir.el b/lisp/vc/vc-dir.el index e225978592..ad25e8aa53 100644 --- a/lisp/vc/vc-dir.el +++ b/lisp/vc/vc-dir.el @@ -390,19 +390,22 @@ vc-dir-update ;; We assume the ewoc is sorted too, which should be the ;; case if we always add entries with vc-dir-update. (setq entries + (let ((entry-dirs + (mapcar (lambda (entry) + (cons (file-name-directory + (directory-file-name (expand-file-name (car entry)))) + entry)) + entries))) ;; Sort: first files and then subdirectories. - ;; XXX: this is VERY inefficient, it computes the directory - ;; names too many times - (sort entries - (lambda (entry1 entry2) - (let ((dir1 (file-name-directory - (directory-file-name (expand-file-name (car entry1))))) - (dir2 (file-name-directory - (directory-file-name (expand-file-name (car entry2)))))) - (cond - ((string< dir1 dir2) t) - ((not (string= dir1 dir2)) nil) - ((string< (car entry1) (car entry2)))))))) + (mapcar #'cdr + (sort entry-dirs + (lambda (pair1 pair2) + (let ((dir1 (car pair1)) + (dir2 (car pair2))) + (cond + ((string< dir1 dir2) t) + ((not (string= dir1 dir2)) nil) + ((string< (cadr pair1) (cadr pair2)))))))))) ;; Insert directory entries in the right places. (let ((entry (car entries)) (node (ewoc-nth vc-ewoc 0)) --------------77B04CEE07377C4B7C735273--