From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2348 invoked from network); 9 Oct 2008 13:02:55 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00 autolearn=ham version=3.2.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 9 Oct 2008 13:02:55 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 77028 invoked from network); 9 Oct 2008 13:02:23 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 9 Oct 2008 13:02:23 -0000 Received: (qmail 25657 invoked by alias); 9 Oct 2008 13:02:02 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 25830 Received: (qmail 25630 invoked from network); 9 Oct 2008 13:02:00 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 9 Oct 2008 13:02:00 -0000 Received: from mail.daysofwonder.com (mail.daysofwonder.com [87.98.213.69]) by bifrost.dotsrc.org (Postfix) with ESMTP id 106B080308BA for ; Thu, 9 Oct 2008 15:01:49 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail.daysofwonder.com (Postfix) with ESMTP id 9B26268088 for ; Thu, 9 Oct 2008 15:01:49 +0200 (CEST) X-Virus-Scanned: by amavisd-new at daysofwonder.com Received: from mail.daysofwonder.com ([127.0.0.1]) by localhost (mail.daysofwonder.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 6LxE390AsJZe for ; Thu, 9 Oct 2008 15:01:41 +0200 (CEST) Received: from sc.dow-test.wanadoo.fr (dow.net8.nerim.net [213.41.185.138]) (Authenticated sender: brice) by mail.daysofwonder.com (Postfix) with ESMTPA id 7394268083 for ; Thu, 9 Oct 2008 15:01:41 +0200 (CEST) Subject: git completion is really slow for some git commands. From: Brice Figureau To: zsh-workers@sunsite.dk Content-Type: text/plain Date: Thu, 09 Oct 2008 15:01:40 +0200 Message-Id: <1223557300.563.31.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.6.3 Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV 0.92.1/8399/Thu Oct 9 14:27:14 2008 on bifrost X-Virus-Status: Clean Hi, I'm a long time user of zsh, and I've always been really pleased by its superior completion system. Right now, I'm running lenny debian package of 4.3.6. Unfortunately git completion, although working fine, is extremely slow as soon as you have a moderately sized git repository. In my case, my checkout have 13000 files and about 6000 commits. git log takes about 15s using 100% CPU to complete on my 2.4GHZ P4 computer. OK, that's now an old computer, but I find that a little bit slow to just sort/split 13000 strings. It all boils down to the following chain of events: * git log completion uses __git_files * _git_files uses "git ls-files". In itself ls-files on this repository on cold cache takes about 70ms (which is short, compared to the 15s of the whole thing). * the result of git ls-files is splitted by \0 and stored in a shell array. This operation takes about 350ms. That's still fast compared to the 15s of the whole execution time. Note: that's not as fast we would think it could be. * this shell array is then passed to _multi_parts for path splitting of each element. This is this operation that takes age. As soon as I change the _multi_parts code to just call a naive compadd and return, the completion is (almost) immediate, and seems to work fine. I understand that the issue might be that git ls-files returns _all_ the files present in the index (ie not only the first level, it recurses the hierarchy). Now, I'm really a zsh completion newbie, so I still fail to see how to optimize the _git_files operation. Does anybody have an idea to speed up the multi_parts thing? And Is it really needed? Many thanks for the answers, -- Brice Figureau