Thread (5 messages) flat view 5 messages, 5 authors, 2016-06-15
STALE3719d

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

From: Luke Lu <hidden>
Date: 2016-06-15 22:43:41
Subsystem: the rest · Maintainer: Linus Torvalds

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 <redacted>
---
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help