gitweb: speed up project listing on large work trees by limiting find depth
Signed-off-by: Luke Lu <git@vicaya.com> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
This commit is contained in:
parent
317efa63fc
commit
ca5e949560
2
Makefile
2
Makefile
@ -165,6 +165,7 @@ GITWEB_CONFIG = gitweb_config.perl
|
|||||||
GITWEB_HOME_LINK_STR = projects
|
GITWEB_HOME_LINK_STR = projects
|
||||||
GITWEB_SITENAME =
|
GITWEB_SITENAME =
|
||||||
GITWEB_PROJECTROOT = /pub/git
|
GITWEB_PROJECTROOT = /pub/git
|
||||||
|
GITWEB_PROJECT_MAXDEPTH = 2007
|
||||||
GITWEB_EXPORT_OK =
|
GITWEB_EXPORT_OK =
|
||||||
GITWEB_STRICT_EXPORT =
|
GITWEB_STRICT_EXPORT =
|
||||||
GITWEB_BASE_URL =
|
GITWEB_BASE_URL =
|
||||||
@ -831,6 +832,7 @@ gitweb/gitweb.cgi: gitweb/gitweb.perl
|
|||||||
-e 's|++GITWEB_HOME_LINK_STR++|$(GITWEB_HOME_LINK_STR)|g' \
|
-e 's|++GITWEB_HOME_LINK_STR++|$(GITWEB_HOME_LINK_STR)|g' \
|
||||||
-e 's|++GITWEB_SITENAME++|$(GITWEB_SITENAME)|g' \
|
-e 's|++GITWEB_SITENAME++|$(GITWEB_SITENAME)|g' \
|
||||||
-e 's|++GITWEB_PROJECTROOT++|$(GITWEB_PROJECTROOT)|g' \
|
-e 's|++GITWEB_PROJECTROOT++|$(GITWEB_PROJECTROOT)|g' \
|
||||||
|
-e 's|"++GITWEB_PROJECT_MAXDEPTH++"|$(GITWEB_PROJECT_MAXDEPTH)|g' \
|
||||||
-e 's|++GITWEB_EXPORT_OK++|$(GITWEB_EXPORT_OK)|g' \
|
-e 's|++GITWEB_EXPORT_OK++|$(GITWEB_EXPORT_OK)|g' \
|
||||||
-e 's|++GITWEB_STRICT_EXPORT++|$(GITWEB_STRICT_EXPORT)|g' \
|
-e 's|++GITWEB_STRICT_EXPORT++|$(GITWEB_STRICT_EXPORT)|g' \
|
||||||
-e 's|++GITWEB_BASE_URL++|$(GITWEB_BASE_URL)|g' \
|
-e 's|++GITWEB_BASE_URL++|$(GITWEB_BASE_URL)|g' \
|
||||||
|
@ -35,6 +35,10 @@ our $GIT = "++GIT_BINDIR++/git";
|
|||||||
#our $projectroot = "/pub/scm";
|
#our $projectroot = "/pub/scm";
|
||||||
our $projectroot = "++GITWEB_PROJECTROOT++";
|
our $projectroot = "++GITWEB_PROJECTROOT++";
|
||||||
|
|
||||||
|
# fs traversing limit for getting project list
|
||||||
|
# the number is relative to the projectroot
|
||||||
|
our $project_maxdepth = "++GITWEB_PROJECT_MAXDEPTH++";
|
||||||
|
|
||||||
# target of the home link on top of all pages
|
# target of the home link on top of all pages
|
||||||
our $home_link = $my_uri || "/";
|
our $home_link = $my_uri || "/";
|
||||||
|
|
||||||
@ -1509,6 +1513,7 @@ sub git_get_projects_list {
|
|||||||
# remove the trailing "/"
|
# remove the trailing "/"
|
||||||
$dir =~ s!/+$!!;
|
$dir =~ s!/+$!!;
|
||||||
my $pfxlen = length("$dir");
|
my $pfxlen = length("$dir");
|
||||||
|
my $pfxdepth = ($dir =~ tr!/!!);
|
||||||
|
|
||||||
File::Find::find({
|
File::Find::find({
|
||||||
follow_fast => 1, # follow symbolic links
|
follow_fast => 1, # follow symbolic links
|
||||||
@ -1519,6 +1524,11 @@ sub git_get_projects_list {
|
|||||||
return if (m!^[/.]$!);
|
return if (m!^[/.]$!);
|
||||||
# only directories can be git repositories
|
# only directories can be git repositories
|
||||||
return unless (-d $_);
|
return unless (-d $_);
|
||||||
|
# don't traverse too deep (Find is super slow on os x)
|
||||||
|
if (($File::Find::name =~ tr!/!!) - $pfxdepth > $project_maxdepth) {
|
||||||
|
$File::Find::prune = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
my $subdir = substr($File::Find::name, $pfxlen + 1);
|
my $subdir = substr($File::Find::name, $pfxlen + 1);
|
||||||
# we check related file in $projectroot
|
# we check related file in $projectroot
|
||||||
|
@ -18,6 +18,7 @@ gitweb_init () {
|
|||||||
our \$version = "current";
|
our \$version = "current";
|
||||||
our \$GIT = "git";
|
our \$GIT = "git";
|
||||||
our \$projectroot = "$(pwd)";
|
our \$projectroot = "$(pwd)";
|
||||||
|
our \$project_maxdepth = 8;
|
||||||
our \$home_link_str = "projects";
|
our \$home_link_str = "projects";
|
||||||
our \$site_name = "[localhost]";
|
our \$site_name = "[localhost]";
|
||||||
our \$site_header = "";
|
our \$site_header = "";
|
||||||
|
Loading…
Reference in New Issue
Block a user