From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Eric S. Raymond" Newsgroups: gmane.emacs.devel Subject: Hideously slow VC status queries fixed Date: Wed, 26 Dec 2007 19:11:13 -0500 (EST) Message-ID: <20071227001113.3EDFE830B6E@snark.thyrsus.com> NNTP-Posting-Host: lo.gmane.org X-Trace: ger.gmane.org 1198714287 6532 80.91.229.12 (27 Dec 2007 00:11:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 27 Dec 2007 00:11:27 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Dec 27 01:11:40 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1J7gLb-0008VO-Mp for ged-emacs-devel@m.gmane.org; Thu, 27 Dec 2007 01:11:39 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1J7gLG-0002Ok-NB for ged-emacs-devel@m.gmane.org; Wed, 26 Dec 2007 19:11:18 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1J7gLC-0002OX-HZ for emacs-devel@gnu.org; Wed, 26 Dec 2007 19:11:14 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1J7gLB-0002OD-Db for emacs-devel@gnu.org; Wed, 26 Dec 2007 19:11:14 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1J7gLB-0002OA-AJ for emacs-devel@gnu.org; Wed, 26 Dec 2007 19:11:13 -0500 Original-Received: from static-71-162-243-5.phlapa.fios.verizon.net ([71.162.243.5] helo=snark.thyrsus.com) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1J7gLB-0005Y5-3I for emacs-devel@gnu.org; Wed, 26 Dec 2007 19:11:13 -0500 Original-Received: by snark.thyrsus.com (Postfix, from userid 23) id 3EDFE830B6E; Wed, 26 Dec 2007 19:11:13 -0500 (EST) X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:85493 Archived-At: It gives me great pleasure to be able to announce that I have found, and fixed, the bug that made C-x v d so godawful much slower than the underlying commands. This one was a truly classic collision of blunders. It should be a warning to us all about the perils of the expedient local hack. When I originally wrote VC mode back in the dark and backward abysm of time, it was for RCS and SCCS. Back then there was no dir-state hook; vc-dired-hook queried the version-control status of each file named in the VC-dired buffer individually. This performed acceptably because code directories averaged far smaller then. Whoever wrote the first dir-state hook (probably for CVS) blundered badly by making the most conservative possible modification to vc-dired. That unknown hacker, may his name be accursed, used dir-state *only for subdirectories*; the status of all files in default-directory was still queried one at a time. He carefully wrote the dir-state hook to use "status -l", not recursing down subdirectories, because he gathered all the subdirectories by walking through the dired listing and applied the dir-state method to each one at a time. People who wrote backends for later VCSes followed suit, so focused on getting their backends minimally working that they failed to notice that the upper-level logic was perversely misdesigned. And this threw away a lot of data; most of the later back ends are like SVN in there's no way to tell the status command not to recurse down directories. So the status information for the *entire file tree* would get queried and parsed as many times as there were non-excluded directory nodes in the tree. Gaaaahhhhh...no *wonder* it was slower than a snail on Quaaludes! All I did to fix this was notice that you *want* dir-state hook to recurse down directory tries -- and then call it exactly once on default-directory. Most of the fix consisted of removing options to suppress the recursion and documenting the new expected behavior of dir-state. Someone should have noticed this a lot sooner. -- Eric S. Raymond What, then is law [government]? It is the collective organization of the individual right to lawful defense." -- Frederic Bastiat, "The Law"