[PATCH] gitweb: Speed up get_projects_list for large source trees

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <git@...>
Date: Tuesday, October 16, 2007 - 5:04 am

Hi, I've been using git for a month now and loving it. This is my  
first ever patch for git using git. I spent sometime to find out why  
the project listing is taking 200s, everytime! I guess that gitweb is  
mostly used to serve bare repositories, which would never encounter  
such problems. It takes .2s, after the patch on my laptop. That's  
1000x improvement for me (on Mac OS X 1.4.10.)

__Luke

Signed-off-by: Luke Lu <git@vicaya.com>
---
gitweb/gitweb.perl |    4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 3064298..a30eef9 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1509,16 +1509,20 @@ sub git_get_projects_list {
		# remove the trailing "/"
		$dir =~ s!/+$!!;
		my $pfxlen = length("$dir");
+		my $pfxdepth = ($dir =~ tr!/!!);
		File::Find::find({
			follow_fast => 1, # follow symbolic links
			follow_skip => 2, # ignore duplicates
+			no_chdir => 1, # don't chdir into every directory
			dangling_symlinks => 0, # ignore dangling symlinks, silently
			wanted => sub {
				# skip project-list toplevel, if we get it.
				return if (m!^[/.]$!);
				# only directories can be git repositories
				return unless (-d $_);
+				# don't traverse too deep (Find is super slow on os x)
+				return if tr!/!! - $pfxdepth > 2 && ($File::Find::prune = 1);
				my $subdir = substr($File::Find::name, $pfxlen + 1);
				# we check related file in $projectroot
--
1.5.3.4


-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] Git homepage: remove all the references to Cogito, Paolo Ciarrocchi, (Mon Oct 15, 5:38 pm)
Re: [PATCH] Git homepage: remove all the references to Cogito, Paolo Ciarrocchi, (Tue Oct 16, 4:01 am)
[PATCH] gitweb: Speed up get_projects_list for large source ..., Luke Lu, (Tue Oct 16, 5:04 am)
Re: [PATCH] gitweb: Speed up get_projects_list for large sou..., Andreas Ericsson, (Tue Oct 16, 12:55 pm)
cogito and remote#branch, was Re: [PATCH] Git homepage: remo..., Johannes Schindelin, (Tue Oct 16, 6:49 am)
Re: remote#branch, Jan Hudec, (Tue Oct 16, 5:09 pm)
Re: remote#branch, Johannes Schindelin, (Tue Oct 16, 5:35 pm)
Re: remote#branch, Jan Hudec, (Sat Oct 27, 4:47 pm)
Re: remote#branch, Johannes Schindelin, (Sat Oct 27, 7:01 pm)
Re: remote#branch, Jan Hudec, (Mon Oct 29, 1:40 pm)
Re: remote#branch, Johannes Schindelin, (Mon Oct 29, 2:32 pm)
Re: remote#branch, Linus Torvalds, (Mon Oct 29, 2:17 pm)
Re: remote#branch, Theodore Tso, (Mon Oct 29, 5:49 pm)
Re: remote#branch, Linus Torvalds, (Mon Oct 29, 6:57 pm)
Re: remote#branch, Johannes Schindelin, (Mon Oct 29, 7:49 pm)
Re: remote#branch, Theodore Tso, (Mon Oct 29, 11:01 pm)
Re: remote#branch, Linus Torvalds, (Tue Oct 30, 12:50 am)
Re: remote#branch, Junio C Hamano, (Mon Oct 29, 11:40 pm)
Re: remote#branch, Theodore Tso, (Tue Oct 30, 12:40 am)
Re: remote#branch, Linus Torvalds, (Tue Oct 30, 12:51 am)
Re: remote#branch, Martin Langhoff, (Tue Oct 30, 8:41 pm)
Re: remote#branch, Jeff King, (Tue Oct 30, 9:43 pm)
Re: remote#branch, Johannes Schindelin, (Tue Oct 30, 11:08 pm)
Re: remote#branch, Martin Langhoff, (Tue Oct 30, 9:49 pm)
Re: remote#branch, Jeff King, (Tue Oct 30, 9:59 pm)
Re: remote#branch, Linus Torvalds, (Tue Oct 30, 8:59 pm)
Re: remote#branch, Johannes Schindelin, (Tue Oct 30, 6:02 am)
Re: remote#branch, Tom Prince, (Tue Oct 30, 1:37 am)
Re: remote#branch, Linus Torvalds, (Tue Oct 30, 10:59 am)
Re: remote#branch, Jan Hudec, (Tue Oct 30, 3:36 pm)
Re: remote#branch, Erik Warendorph, (Wed Oct 31, 3:29 pm)
Re: remote#branch, Linus Torvalds, (Tue Oct 30, 3:53 pm)
Re: remote#branch, Tom Prince, (Tue Oct 30, 12:02 pm)
Re: remote#branch, Linus Torvalds, (Tue Oct 30, 1:39 pm)
Re: remote#branch, Matthieu Moy, (Tue Oct 30, 1:49 pm)
Re: remote#branch, Linus Torvalds, (Tue Oct 30, 1:58 pm)
Re: remote#branch, Linus Torvalds, (Tue Oct 30, 2:19 pm)
Re: remote#branch, Pascal Obry, (Tue Oct 30, 3:18 pm)
Re: remote#branch, Linus Torvalds, (Tue Oct 30, 3:38 pm)
Re: remote#branch, Jeff King, (Tue Oct 30, 7:58 pm)
Re: remote#branch, Petr Baudis, (Wed Oct 31, 1:13 pm)
Re: remote#branch, David Kastrup, (Wed Oct 31, 2:39 am)
Re: remote#branch, Pascal Obry, (Wed Oct 31, 5:34 am)
Re: remote#branch, Robin Rosenberg, (Wed Oct 31, 4:25 am)
Re: remote#branch, Wincent Colaiuta, (Wed Oct 31, 4:16 am)
Re: remote#branch, Randal L. Schwartz, (Tue Oct 30, 4:15 pm)
Re: remote#branch, Nicolas Pitre, (Tue Oct 30, 4:36 pm)
Re: remote#branch, Linus Torvalds, (Tue Oct 30, 4:30 pm)
Re: remote#branch, Pascal Obry, (Tue Oct 30, 3:15 pm)