Skip to content

Commit 07b257f

Browse files
jnarebgitster
authored andcommitted
gitweb: Faster project search
Before searching by some field the information we search for must be filled in, but we do not have to fill other fields that are not involved in the search. To be able to request filling only specified fields, fill_project_list_info() was enhanced in previous commit to take additional parameters which specify part of projects info to fill. This way we can limit doing expensive calculations (like running git-for-each-ref to get 'age' / "Last changed" info) to doing those only for projects which we will show as search results. This commit actually uses this interface, changing gitweb code from the following behavior fill all project info on all projects search projects to behaving like this pseudocode fill search fields on all projects search projects fill all project info on search results With this commit the number of git commands used to generate search results is 2*<matched projects> + 1, and depends on number of matched projects rather than number of all projects (all repositories). Note: this is 'git for-each-ref' to find last activity, and 'git config' for each project, and 'git --version' once. Example performance improvements, for search that selects 2 repositories out of 12 in total: * Before (warm cache): "This page took 0.867151 seconds and 27 git commands to generate." * After (warm cache): "This page took 0.673643 seconds and 5 git commands to generate." Now imagine that they are 5 repositories out of 5000, and cold or trashed cache case. Signed-off-by: Jakub Narebski <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2e3291a commit 07b257f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

gitweb/gitweb.perl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2987,6 +2987,10 @@ sub search_projects_list {
29872987
return @$projlist
29882988
unless ($tagfilter || $searchtext);
29892989

2990+
# searching projects require filling to be run before it;
2991+
fill_project_list_info($projlist,
2992+
$tagfilter ? 'ctags' : (),
2993+
$searchtext ? ('path', 'descr') : ());
29902994
my @projects;
29912995
PROJECT:
29922996
foreach my $pr (@$projlist) {
@@ -5387,12 +5391,13 @@ sub git_project_list_body {
53875391
# filtering out forks before filling info allows to do less work
53885392
@projects = filter_forks_from_projects_list(\@projects)
53895393
if ($check_forks);
5390-
@projects = fill_project_list_info(\@projects);
5391-
# searching projects require filling to be run before it
5394+
# search_projects_list pre-fills required info
53925395
@projects = search_projects_list(\@projects,
53935396
'searchtext' => $searchtext,
53945397
'tagfilter' => $tagfilter)
53955398
if ($tagfilter || $searchtext);
5399+
# fill the rest
5400+
@projects = fill_project_list_info(\@projects);
53965401

53975402
$order ||= $default_projects_order;
53985403
$from = 0 unless defined $from;

0 commit comments

Comments
 (0)