[RFC/PATCH 3/3] gitweb: Fill project details lazily when caching

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If caching is turned on project details can be filled in already from
the cache.  When refreshing project info details for all project (when
cache is stale and has to be refreshed) generate projects info only if
modification time (as returned by lstat()) of projects repository
gitdir changed.

This way we can avoid hitting repository refs, object database and
repository config at the cost of additional lstat.

Signed-off-by: Jakub Narebski <jnareb@xxxxxxxxx>
---
This is an idea for further improvement of 'projects list caching'.
Could you please: 

 1.) comment if it is a good idea, or why it works, or why it
     couldn't work :),  

 2.) check if this change gives any improvements in performance on
     real data; note that testing would require updating repositories
     if test on generated data was done, or gathering statistics over
     larger time period if it was tested on "live" set.

Thanks in advance.

 gitweb/gitweb.perl |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 5527378..1741628 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -3487,8 +3487,14 @@ sub git_patchset_body {
 sub git_get_projects_details {
 	my ($projlist, $check_forks) = @_;
 
+	use File::stat;
 	my @projects;
 	foreach my $pr (@$projlist) {
+		my $mtime;
+		if ($cached && $pr->{'mtime'}) {
+			$mtime = lstat("$projectroot/$pr->{'path'}")->mtime;
+			next if ($mtime <= $pr->{'mtime'});
+		}
 		my (@aa) = git_get_last_activity($pr->{'path'});
 		unless (@aa) {
 			next;
@@ -3513,6 +3519,9 @@ sub git_get_projects_details {
 				$pr->{'forks'} = 0;
 			}
 		}
+		if ($cached) {
+			$pr->{'mtime'} = $mtime;
+		}
 		push @projects, $pr;
 	}
 	return @projects;
-- 
1.5.4.3.453.gc1ad83

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux