git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Jakub Narebski <jnareb@gmail.com>
Date
Mar 17, 2008, 15:09 UTC
Message-ID
<1205766570-13550-4-git-send-email-jnareb@gmail.com>
In-Reply-To
<1205766570-13550-1-git-send-email-jnareb@gmail.com>

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@gmail.com>
---
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
Previous: Jakub NarebskiNext: Petr Baudis
Message 9 of 12 in “gitweb: Support caching projects list”
  1. 0/3 gitweb: Support caching projects listJakub Narebski, Mar 17, 2008
  2. 1/3 gitweb: Separate @projects population into git_get_projects_details()Jakub Narebski, Mar 17, 2008
  3. 2/3 gitweb: Support caching projects listJakub Narebski, Mar 17, 2008
  4. Frank LichtenheldMar 17, 2008
  5. Jakub NarebskiMar 17, 2008
  6. Frank LichtenheldMar 17, 2008
  7. Jakub NarebskiMar 17, 2008
  8. 2/3 gitweb: Support caching projects listJakub Narebski, Mar 17, 2008
  9. 3/3 gitweb: Fill project details lazily when cachingJakub Narebski, Mar 17, 2008
  10. Petr BaudisMar 18, 2008
  11. Jakub NarebskiMar 18, 2008
  12. Frank LichtenheldMar 18, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.