Gitweb caching changes v2
cover Gitweb caching changes v2
Evening everyone,
This is the latest incarnation of gitweb w/ caching. This is finally at the point where it should probably start either being considered for inclusion or mainline, or I need to accept that this will never get in and more perminantely fork (as is the case with Fedora where this is going in as gitweb-caching as a parrallel rpm package).
That said this brings the base up to mainline (again), it updates a number of elements in the caching engine, and this is a much cleaner break-out of the tree vs. what I am currently developing against.
New things known to work:
- Better breakout
- You can actually disable the cache now
- John 'Warthog9' Hawley
John 'Warthog9' Hawley (6):
GITWEB - Load Checking
GITWEB - Missmatching git w/ gitweb
GITWEB - Add git:// link to summary pages
GITWEB - Makefile changes
GITWEB - File based caching layer
GITWEB - Separate defaults from main file
.gitignore | 1 + Makefile | 15 +- gitweb/Makefile | 14 + gitweb/cache.pm | 293 +++++++ gitweb/gitweb.css | 6 + gitweb/gitweb.perl | 1821 ++++++++++++++++++++----------------------- gitweb/gitweb_defaults.perl | 468 +++++++++++ 7 files changed, 1651 insertions(+), 967 deletions(-) create mode 100644 gitweb/Makefile create mode 100644 gitweb/cache.pm create mode 100644 gitweb/gitweb_defaults.perl
PATCH 1/6 GITWEB - Load Checking
This changes the behavior, slightly, of gitweb so that it verifies that the box isn't inundated with before attempting to serve gitweb. If the box is overloaded, it basically returns a 503 server unavailable until the load falls below the defined threshold. This helps dramatically if you have a box that's I/O bound, reaches a certain load and you don't want gitweb, the I/O hog that it is, increasing the pain the server is already undergoing.
adds $maxload configuration variable. Default is a load of 300, which for most cases should never be hit.
Please note this makes the assumption that /proc/loadavg exists as there is no good way to read load averages on a great number of platforms [READ: Windows], or that it's reasonably accurate.
--- gitweb/gitweb.perl | 24 ++++++++++++++++++++++++ 1 files changed, 24 insertions(+), 0 deletions(-)
gitweb/gitweb.perl +24 -0
@@ -221,6 +221,11 @@ our %avatar_size = ( 'double' => 32 ); +# Used to set the maximum load that we will still respond to gitweb queries. +# if we exceed this than we do the processing to figure out if there's a mirror +# and redirect to it, or to just return 503 server busy +our $maxload = 300; + # You define site-wide feature defaults here; override them with # $GITWEB_CONFIG as necessary. our %feature = (
@@ -551,6 +556,25 @@ if (-e $GITWEB_CONFIG) { do $GITWEB_CONFIG_SYSTEM if -e $GITWEB_CONFIG_SYSTEM; } +# loadavg throttle +sub get_loadavg() { + my $load; + my @loads; + + open($load, '<', '/proc/loadavg') or return 0; + @loads = split(/\s+/, scalar <$load>); + close($load); + return $loads[0]; +} + +if (get_loadavg() > $maxload) { + print "Content-Type: text/plain\n"; + print "Status: 503 Excessive load on server\n"; + print "\n"; + print "The load average on the server is too high\n"; + exit 0; +} + # version of the core git binary our $git_version = qx("$GIT" --version) =~ m/git version (.*)$/ ? $1 : "unknown"; $number_of_git_cmds++;
PATCH 2/6 GITWEB - Missmatching git w/ gitweb
This adds $missmatch_git so that gitweb can run with a miss-matched git install. Gitweb, generally, runs fine on a very broad range of git versions, but it's not always practicle or useful to upgrade it every time you upgrade git.
This allows the administrator to realize they are miss-matched, and should they be so inclined, disable the check entirely and run in a miss-matched fasion.
This is more here to give an obvious warning as to whats going on vs. silently failing.
--- gitweb/gitweb.perl | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+), 0 deletions(-)
gitweb/gitweb.perl +22 -0
@@ -221,6 +221,9 @@ our %avatar_size = ( 'double' => 32 ); +# This is here to allow for missmatch git & gitweb versions +our $missmatch_git = ''; + # Used to set the maximum load that we will still respond to gitweb queries. # if we exceed this than we do the processing to figure out if there's a mirror # and redirect to it, or to just return 503 server busy
@@ -579,6 +582,25 @@ if (get_loadavg() > $maxload) { our $git_version = qx("$GIT" --version) =~ m/git version (.*)$/ ? $1 : "unknown"; $number_of_git_cmds++; +# There's a pretty serious flaw that we silently fail if git doesn't find something it needs +# a quick and simple check is to have gitweb do a simple check - are we running on the same +# version of git that we shipped with - if not, throw up an error so that people doing +# first installs don't have to debug perl to figure out whats going on +if ( + $git_version ne $version + && + $missmatch_git eq '' +){ + git_header_html(); + print "<p><b>*** Warning ***</b></p>\n"; + print "<p>\n"; + print "This version of gitweb was compiled for <b>$version</b> however git version <b>$git_version</b> was found<br/>\n"; + print "If you are sure this version of git works with this version of gitweb - please define <b>\$missmatch_git</b> to a non empty string in your git config file.\n"; + print "</p>\n"; + git_footer_html(); + exit; +} + $projects_list ||= $projectroot; # ======================================================================
PATCH 3/6 GITWEB - Add git:// link to summary pages
This adds a git:// link to the summary pages should a common $gitlinkurl be defined (default is nothing defined, thus nothing shown)
This does make the assumption that the git trees share a common path, and nothing to date is known to actually make use of the link
--- gitweb/gitweb.perl | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)
gitweb/gitweb.perl +8 -0
@@ -224,6 +224,10 @@ our %avatar_size = ( # This is here to allow for missmatch git & gitweb versions our $missmatch_git = ''; +#This is here to deal with an extra link on the summary pages - if it's left blank +# this link will not be shwon. If it's set, this will be prepended to the repo and used +our $gitlinkurl = ''; + # Used to set the maximum load that we will still respond to gitweb queries. # if we exceed this than we do the processing to figure out if there's a mirror # and redirect to it, or to just return 503 server busy
@@ -4454,6 +4458,10 @@ sub git_project_list_body { $cgi->a({-href => href(project=>$pr->{'path'}, action=>"log")}, "log") . " | " . $cgi->a({-href => href(project=>$pr->{'path'}, action=>"tree")}, "tree") . ($pr->{'forks'} ? " | " . $cgi->a({-href => href(project=>$pr->{'path'}, action=>"forks")}, "forks") : '') . + if( $gitlinkurl ne '' ){ + print " | ". $cgi->a({-href => "git://$gitlinkurl/".esc_html($pr->{'path'})}, "git"); + } + print "". "</td>\n" . "</tr>\n"; }
PATCH 4/6 GITWEB - Makefile changes
This adjust the makefiles so that you can do such things as
make gitweb
from the top level make tree, or if your in the gitweb directory itself typing
make
will call back up to the main Makefile and build gitweb
--- Makefile | 4 +++- gitweb/Makefile | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletions(-) create mode 100644 gitweb/Makefile
Makefile +3 -1
@@ -1509,6 +1509,8 @@ $(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl chmod +x $@+ && \ mv $@+ $@ +.PHONY: gitweb +gitweb: gitweb/gitweb.cgi ifdef JSMIN OTHER_PROGRAMS += gitweb/gitweb.cgi gitweb/gitweb.min.js gitweb/gitweb.cgi: gitweb/gitweb.perl gitweb/gitweb.min.js
@@ -1537,7 +1539,7 @@ endif -e 's|++GITWEB_JS++|$(GITWEB_JS)|g' \ -e 's|++GITWEB_SITE_HEADER++|$(GITWEB_SITE_HEADER)|g' \ -e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g' \ - $< >$@+ && \ + $(patsubst %.cgi,%.perl,$@) >$@+ && \ chmod +x $@+ && \ mv $@+ $@
gitweb/Makefile new file +14 -0
@@ -0,0 +1,14 @@ +SHELL = /bin/bash + +FILES = gitweb.cgi + +.PHONY: $(FILES) + +all: $(FILES) + +$(FILES): + $(MAKE) $(MFLAGS) -C ../ -f Makefile gitweb/$@ + +clean: + rm -rf $(FILES) +
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 6/6 GITWEB - Separate defaults from main file
This is an attempt to break out the default values & associated documentation from the main gitweb file so that it's easier to browse / read and understand without the associated code involved.
This helps by making defaults self contained with their documentation making it easier for someone to read through things and find what they want
This is also a not-so-subtle start of trying to break up gitweb into separate files for easier maintainability, having everything in a single file is just a mess and makes the whole thing more complicated than it needs to be. This is a bit of a baby step towards breaking it up for easier maintenance.
--- .gitignore | 1 + Makefile | 15 +- gitweb/Makefile | 2 +- gitweb/gitweb.perl | 515 +++++-------------------------------------- gitweb/gitweb_defaults.perl | 468 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 537 insertions(+), 464 deletions(-) create mode 100644 gitweb/gitweb_defaults.perl
.gitignore +1 -0
@@ -151,6 +151,7 @@ /git-core-*/?* /gitk-git/gitk-wish /gitweb/gitweb.cgi +/gitweb/gitweb_defaults.pl /test-chmtime /test-ctype /test-date
Makefile +9 -6
@@ -1510,14 +1510,16 @@ $(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl mv $@+ $@ .PHONY: gitweb -gitweb: gitweb/gitweb.cgi +gitweb: gitweb/gitweb.cgi gitweb/gitweb_defaults.pl ifdef JSMIN -OTHER_PROGRAMS += gitweb/gitweb.cgi gitweb/gitweb.min.js -gitweb/gitweb.cgi: gitweb/gitweb.perl gitweb/gitweb.min.js +OTHER_PROGRAMS += gitweb/gitweb.cgi gitweb/gitweb.min.js gitweb/gitweb_defaults.pl +gitweb/gitweb.cgi gitweb/gitweb_defaults.pl: gitweb/gitweb.perl gitweb/gitweb.min.js gitweb/gitweb_defaults.perl else -OTHER_PROGRAMS += gitweb/gitweb.cgi -gitweb/gitweb.cgi: gitweb/gitweb.perl +OTHER_PROGRAMS += gitweb/gitweb.cgi gitweb/gitweb_defaults.pl +gitweb/gitweb.cgi: gitweb/gitweb_defaults.pl +gitweb/gitweb.cgi gitweb/gitweb_defaults.pl: gitweb/gitweb.perl gitweb/gitweb_defaults.perl endif + #$(QUIET_GEN)$(RM) $@ $@+ && $(QUIET_GEN)$(RM) $@ $@+ && \ sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \ -e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \
@@ -1539,7 +1541,7 @@ endif -e 's|++GITWEB_JS++|$(GITWEB_JS)|g' \ -e 's|++GITWEB_SITE_HEADER++|$(GITWEB_SITE_HEADER)|g' \ -e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g' \ - $(patsubst %.cgi,%.perl,$@) >$@+ && \ + $(patsubst %.cgi,%.perl,$(patsubst %.pl, %.perl, $@)) >$@+ && \ chmod +x $@+ && \ mv $@+ $@
@@ -1913,6 +1915,7 @@ clean: $(MAKE) -C Documentation/ clean ifndef NO_PERL $(RM) gitweb/gitweb.cgi + $(RM) gitweb/gitweb_defaults.pl $(MAKE) -C perl clean endif $(MAKE) -C templates/ clean
gitweb/Makefile +1 -1
@@ -1,6 +1,6 @@ SHELL = /bin/bash -FILES = gitweb.cgi +FILES = gitweb.cgi gitweb_defaults.pl .PHONY: $(FILES)
gitweb/gitweb.perl +58 -457
524 lines not on this page · raw message
gitweb/gitweb_defaults.perl new file +468 -0
468 lines not on this page · raw message
Re: [PATCH 6/6] GITWEB - Separate defaults from main file
Quoted 8 lines · "John 'Warthog9' Hawley" <[email protected]> writes:
This is an attempt to break out the default values & associated documentation from the main gitweb file so that it's easier to browse / read and understand without the associated code involved.
This helps by making defaults self contained with their documentation making it easier for someone to read through things and find what they want
Quoted 5 lines
This is also a not-so-subtle start of trying to break up gitweb into separate files for easier maintainability, having everything in a single file is just a mess and makes the whole thing more complicated than it needs to be. This is a bit of a baby step towards breaking it up for easier maintenance.
The question is if easier maintenance and development by spliting gitweb for developers offsets ease of install for users.
Quoted 1 line
Signed-off-by John 'Warthog9' Hawley <[email protected]>
Signoff mismatch.
Quoted 15 lines
--- .gitignore | 1 + Makefile | 15 +- gitweb/Makefile | 2 +- gitweb/gitweb.perl | 515 +++++-------------------------------------- gitweb/gitweb_defaults.perl | 468 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 537 insertions(+), 464 deletions(-) create mode 100644 gitweb/gitweb_defaults.perl.gitignore +0
-0
.gitignore line 154
Quoted 4 lines
.gitignore +1
-0@@ -151,6 +151,7 @@ /git-core-*/?* /gitk-git/gitk-wish /gitweb/gitweb.cgi +/gitweb/gitweb_defaults.pl
Hmmm... gitweb/gitweb_defaults.perl as source file, and gitweb/gitweb_defaults.pl as generated file? Wouldn't it be better to go with the convention used elsewhere in gitweb and use gitweb/gitweb_defaults.perl.in or gitweb/gitweb_defaults.pl.in as source file?
Quoted 17 lines
.gitignore +0
-0/test-chmtime /test-ctype /test-dateMakefile +2
-3@@ -1510,14 +1510,16 @@ $(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl mv $@+ $@ .PHONY: gitweb -gitweb: gitweb/gitweb.cgi +gitweb: gitweb/gitweb.cgi gitweb/gitweb_defaults.pl ifdef JSMIN -OTHER_PROGRAMS += gitweb/gitweb.cgi gitweb/gitweb.min.js -gitweb/gitweb.cgi: gitweb/gitweb.perl gitweb/gitweb.min.js +OTHER_PROGRAMS += gitweb/gitweb.cgi gitweb/gitweb.min.js gitweb/gitweb_defaults.pl
Makefile $(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl · line 1523
Quoted 10 lines
Makefile +5
-2+gitweb/gitweb.cgi gitweb/gitweb_defaults.pl: gitweb/gitweb.perl gitweb/gitweb.min.js gitweb/gitweb_defaults.perl else -OTHER_PROGRAMS += gitweb/gitweb.cgi -gitweb/gitweb.cgi: gitweb/gitweb.perl +OTHER_PROGRAMS += gitweb/gitweb.cgi gitweb/gitweb_defaults.pl +gitweb/gitweb.cgi: gitweb/gitweb_defaults.pl +gitweb/gitweb.cgi gitweb/gitweb_defaults.pl: gitweb/gitweb.perl gitweb/gitweb_defaults.perl endif + #$(QUIET_GEN)$(RM) $@ $@+ &&
What this line is about?
Makefile endif · line 1544
Quoted 9 lines
Makefile +0
-0$(QUIET_GEN)$(RM) $@ $@+ && \ sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \Makefile +1
-1-e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \@@ -1539,7 +1541,7 @@ endif -e 's|++GITWEB_JS++|$(GITWEB_JS)|g' \ -e 's|++GITWEB_SITE_HEADER++|$(GITWEB_SITE_HEADER)|g' \ -e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g' \ - $(patsubst %.cgi,%.perl,$@) >$@+ && \ + $(patsubst %.cgi,%.perl,$(patsubst %.pl, %.perl, $@)) >$@+ && \
Why the slightly inconsistent style ("%.cgi,%perl" vs "%.pl, %perl")?
Also wouldn't all replacements be in the new gitweb_defaults file, so there would be no need then to do replacements for gitweb.cgi?
Oh, I see there is at least one that stayed in gitweb.perl: $version
Quoted 28 lines
Makefile +1
-0chmod +x $@+ && \ mv $@+ $@@@ -1913,6 +1915,7 @@ clean: $(MAKE) -C Documentation/ clean ifndef NO_PERL $(RM) gitweb/gitweb.cgi + $(RM) gitweb/gitweb_defaults.pl $(MAKE) -C perl clean endif $(MAKE) -C templates/ cleangitweb/Makefile +1
-1@@ -1,6 +1,6 @@ SHELL = /bin/bash -FILES = gitweb.cgi +FILES = gitweb.cgi gitweb_defaults.pl .PHONY: $(FILES)gitweb/gitweb.perl +0
-0
gitweb/gitweb.perl our $version = "++GIT_VERSION++"; · line 38
Quoted 3 lines
gitweb/gitweb.perl +0
-0@@ -36,466 +36,67 @@ our $version = "++GIT_VERSION++"; our $my_url = $cgi->url(); our $my_uri = $cgi->url(-absolute => 1);
[cut deletion]
Quoted 48 lines
gitweb/gitweb.perl +48
-0+# Define and than setup our configuration +# +our( + $VERSION, + $path_info, + $GIT, + $projectroot, + $project_maxdepth, + $home_link, + $home_link_str, + $site_name, + $site_header, + $home_text, + $site_footer, + @stylesheets, + $stylesheet, + $logo, + $favicon, + $javascript, + $logo_url, + $logo_label, + $projects_list, + $projects_list_description_width, + $default_projects_order, + $export_ok, + $export_auth_hook, + $strict_export, + @git_base_url_list, + $default_blob_plain_mimetype, + $default_text_plain_charset, + $mimetypes_file, + $missmatch_git, + $gitlinkurl, + $maxload, + $cache_enable, + $minCacheTime, + $maxCacheTime, + $cachedir, + $backgroundCache, + $nocachedata, + $nocachedatabin, + $fullhashpath, + $fullhashbinpath, + $export_auth_hook, + %known_snapshot_format_aliases, + %known_snapshot_formats, + $path_info, + $fallback_encoding,
gitweb/gitweb.perl our $version = "++GIT_VERSION++"; · line 97
Quoted 10 lines
gitweb/gitweb.perl +9
-0+ %avatar_size, + $project_maxdepth, + $headerRefresh, + $base_url, + $projects_list_description_width, + $default_projects_order, + $prevent_xss, + @diff_opts, + %feature );
Why this block is required? Why not have variables defined (using "our") in gitweb_defaults file?
[cut deletion]
Quoted 10 lines
gitweb/gitweb.perl +1
-0+do 'gitweb_defaults.pl'; sub gitweb_get_feature { my ($name) = @_;gitweb/gitweb_defaults.perl new file +0
-0
gitweb/gitweb_defaults.perl line 10
Quoted 10 lines
gitweb/gitweb_defaults.perl new file +10
-0@@ -0,0 +1,468 @@ +# gitweb - simple web interface to track changes in git repositories +# +# (C) 2005-2006, Kay Sievers <[email protected]> +# (C) 2005, Christian Gierke +# +# This program is licensed under the GPLv2 + +# Base URL for relative URLs in gitweb ($logo, $favicon, ...), +# needed and used only for URLs with nonempty PATH_INFO +$base_url = $my_url;
Why not "our $base_url = $my_url;"?
[cut]
Quoted 1 line
gitweb/gitweb_defaults.perl new file +1
-0+1;
Signature · 3 lines
Jakub Narebski Poland ShadeHawk on #git
Re: [PATCH 6/6] GITWEB - Separate defaults from main file
Quoted 8 lines
Quoted 5 lines
This is also a not-so-subtle start of trying to break up gitweb into separate files for easier maintainability, having everything in a single file is just a mess and makes the whole thing more complicated than it needs to be. This is a bit of a baby step towards breaking it up for easier maintenance.
The question is if easier maintenance and development by spliting gitweb for developers offsets ease of install for users.
This would just get dropped into the same location that gitweb.cgi exists in, there is no real difference in installation, and thus I can't see this as an issue for users.
Quoted 15 lines
Quoted 2 lines
Signed-off-by John 'Warthog9' Hawley <[email protected]>Signoff mismatch.
Quoted 10 lines
--- .gitignore | 1 + Makefile | 15 +- gitweb/Makefile | 2 +- gitweb/gitweb.perl | 515 +++++-------------------------------------- gitweb/gitweb_defaults.perl | 468 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 537 insertions(+), 464 deletions(-) create mode 100644 gitweb/gitweb_defaults.perl
Quoted 15 lines
.gitignore line 154
Quoted 9 lines
.gitignore +1
-0@@ -151,6 +151,7 @@ /git-core-*/?* /gitk-git/gitk-wish /gitweb/gitweb.cgi +/gitweb/gitweb_defaults.plHmmm... gitweb/gitweb_defaults.perl as source file, and
gitweb/gitweb_defaults.plas generated file? Wouldn't it be better to go with the convention used elsewhere in gitweb and use gitweb/gitweb_defaults.perl.in or gitweb/gitweb_defaults.pl.in as source file?
I think you got confused, the committed file is .perl the generated file is .pl.
Quoted 3 lines
.gitignore line 155
Quoted 1 line
.gitignore +1
-0+ #$(QUIET_GEN)$(RM) $@ $@+ &&What this line is about?
Cruft, thought I had deleted and excluded it, won't be there in next version.
Quoted 12 lines
.gitignore endif · line 1544
Quoted 10 lines
.gitignore +1
-1$(QUIET_GEN)$(RM) $@ $@+ && \ sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \ -e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \@@ -1539,7 +1541,7 @@ endif -e 's|++GITWEB_JS++|$(GITWEB_JS)|g' \ -e 's|++GITWEB_SITE_HEADER++|$(GITWEB_SITE_HEADER)|g' \ -e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g' \ - $(patsubst %.cgi,%.perl,$@) >$@+ && \ + $(patsubst %.cgi,%.perl,$(patsubst %.pl, %.perl, $@)) >$@+ && \Why the slightly inconsistent style ("%.cgi,%perl" vs "%.pl, %perl")?
Considering that the defaults is more of an include vs. a cgi it probably shouldn't share the standard expected executable suffix, thus I used .pl. Could just as easily change it to .pm, or something else but I think it would make the most sense to leave things we are expecting the webserver to directly execute as .cgi, and includes as a different suffix.
Quoted 2 lines
Also wouldn't all replacements be in the new
gitweb_defaultsfile, so there would be no need then to do replacements for gitweb.cgi?
Not all replacements are done in one or the other, and since it's basically a NOP to perform the full set of replacements on both files that seemed the easiest way to ensure they were done in both places.
Quoted 2 lines
Oh, I see there is at least one that stayed in gitweb.perl: $version
<snip>
Quoted 53 lines
Quoted 53 lines
.gitignore +53
-0+# Define and than setup our configuration +# +our( + $VERSION, + $path_info, + $GIT, + $projectroot, + $project_maxdepth, + $home_link, + $home_link_str, + $site_name, + $site_header, + $home_text, + $site_footer, + @stylesheets, + $stylesheet, + $logo, + $favicon, + $javascript, + $logo_url, + $logo_label, + $projects_list, + $projects_list_description_width, + $default_projects_order, + $export_ok, + $export_auth_hook, + $strict_export, + @git_base_url_list, + $default_blob_plain_mimetype, + $default_text_plain_charset, + $mimetypes_file, + $missmatch_git, + $gitlinkurl, + $maxload, + $cache_enable, + $minCacheTime, + $maxCacheTime, + $cachedir, + $backgroundCache, + $nocachedata, + $nocachedatabin, + $fullhashpath, + $fullhashbinpath, + $export_auth_hook, + %known_snapshot_format_aliases, + %known_snapshot_formats, + $path_info, + $fallback_encoding, + %avatar_size, + $project_maxdepth, + $headerRefresh, + $base_url, + $projects_list_description_width,
Quoted 8 lines
.gitignore
Quoted 5 lines
.gitignore +4
-0+ $default_projects_order, + $prevent_xss, + @diff_opts, + %feature );Why this block is required? Why not have variables defined (using "our") in
gitweb_defaultsfile?
Wanted to make sure things were properly defined, if in an unexpected state, should a user have gitweb.cgi in place but not the defaults.
Quoted 17 lines
[cut deletion]
Quoted 14 lines
.gitignore +1
-0+do 'gitweb_defaults.pl'; sub gitweb_get_feature { my ($name) = @_;gitweb/gitweb_defaults.perl new file +4
-0@@ -0,0 +1,468 @@ +# gitweb - simple web interface to track changes in git repositories +# +# (C) 2005-2006, Kay Sievers <[email protected]> +# (C) 2005, Christian Gierke
Quoted 8 lines
gitweb/gitweb_defaults.perl line 10
Quoted 6 lines
gitweb/gitweb_defaults.perl new file +6
-0+# +# This program is licensed under the GPLv2 + +# Base URL for relative URLs in gitweb ($logo, $favicon, ...), +# needed and used only for URLs with nonempty PATH_INFO +$base_url = $my_url;Why not "our $base_url = $my_url;"?
same reason as the other 'our' includes above, though why this ended up as a separate patch vs. the rest of the file I don't know.
- John 'Warthog9' Hawley
Re: [PATCH 6/6] GITWEB - Separate defaults from main file
Quoted 6 lines · J.H.
Quoted 6 lines
Quoted 5 lines
This is also a not-so-subtle start of trying to break up gitweb into separate files for easier maintainability, having everything in a single file is just a mess and makes the whole thing more complicated than it needs to be. This is a bit of a baby step towards breaking it up for easier maintenance.
Quoted 6 lines
Quoted 2 lines
The question is if easier maintenance and development by spliting gitweb for developers offsets ease of install for users.
This would just get dropped into the same location that gitweb.cgi exists in, there is no real difference in installation, and thus I can't see this as an issue for users.
To be more exact you have to know that you have to drop _generated files_, which means (for this version of patch) gitweb.cgi and gitweb_defaults.pl (or whatever the generated file with config variables would be named).
ATTENTION!
Your changes would make stop working all gitweb tests. Currently they do some magic with generated gitweb config file "$(pwd)/gitweb_config.perl" set via GITWEB_CONFIG configuration variable to be able to run _unprocessed_ gitweb/gitweb.perl (without any substitutions). This allow to run tests on "live" version of gitweb.
After your changes it would be no longer possible, at least not if we want to be sure that we test the same version of gitweb as gitweb_defaults.
It would probably mean that we need to move to testing built version, i.e. gitweb.cgi, not gitweb.perl
Quoted 26 lines
Quoted 10 lines
Quoted 10 lines
--- .gitignore | 1 + Makefile | 15 +- gitweb/Makefile | 2 +- gitweb/gitweb.perl | 515 +++++-------------------------------------- gitweb/gitweb_defaults.perl | 468 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 537 insertions(+), 464 deletions(-) create mode 100644 gitweb/gitweb_defaults.perlQuoted 15 lines
.gitignore line 154
Quoted 9 lines
.gitignore +1
-0@@ -151,6 +151,7 @@ /git-core-*/?* /gitk-git/gitk-wish /gitweb/gitweb.cgi +/gitweb/gitweb_defaults.plHmmm... gitweb/gitweb_defaults.perl as source file, and
gitweb/gitweb_defaults.plas generated file? Wouldn't it be better to go with the convention used elsewhere in gitweb and use gitweb/gitweb_defaults.perl.in or gitweb/gitweb_defaults.pl.in as source file?
Quoted 2 lines
I think you got confused, the committed file is .perl the generated file is .pl.
Maybe I wasn't entirely clean. I meant that the committed source file should perhaps have *.in extension to denote that it is to be processed via variable substitution, so it would be
committed file: gitweb/gitweb_defaults.pl.in
generated file: gitweb/gitweb_defaults.pl
or whatever name (*.pm?) we agree on.
Quoted 12 lines
Quoted 11 lines
.gitignore endif · line 1544
Quoted 9 lines
.gitignore +1
-1$(QUIET_GEN)$(RM) $@ $@+ && \ sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \ -e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \@@ -1539,7 +1541,7 @@ endif -e 's|++GITWEB_JS++|$(GITWEB_JS)|g' \ -e 's|++GITWEB_SITE_HEADER++|$(GITWEB_SITE_HEADER)|g' \ -e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g' \ - $(patsubst %.cgi,%.perl,$@) >$@+ && \ + $(patsubst %.cgi,%.perl,$(patsubst %.pl, %.perl, $@)) >$@+ && \Why the slightly inconsistent style ("%.cgi,%perl" vs "%.pl, %perl")?
Quoted 6 lines
Considering that the defaults is more of an include vs. a cgi it probably shouldn't share the standard expected executable suffix, thus I used .pl. Could just as easily change it to .pm, or something else but I think it would make the most sense to leave things we are expecting the webserver to directly execute as .cgi, and includes as a different suffix.
I was not asking about that, but about
+ $(patsubst %.cgi,%.perl,$(patsubst %.pl, %.perl, $@)) >$@+ && \
vs
+ $(patsubst %.cgi,%.perl,$(patsubst %.pl,%.perl,$@)) >$@+ && \
But after thinking about it a bit, and consulting make documentation (in particular definition of $@ variable) this rule shouldn't work at all.
`$@'
The file name of the target of the rule. If the target is an archive member, then $@' is the name of the archive file. In a pattern rule that has multiple targets (*note Introduction to Pattern Rules: Pattern Intro.), $@' is the name of whichever target caused the rule's commands to be run.
What we need is to run pattern substitution for _two_ files, perhaps using the for loop.
Also I think the order of substitutions would be better to be reversed:
$(patsubst %.pl,%.perl,$(patsubst %.cgi,%.perl,$FILE)) >$FILE+
This way the gitweb_defaults file can even have *.perl extension
Quoted 11 lines
Quoted 2 lines
Also wouldn't all replacements be in the new
gitweb_defaultsfile, so there would be no need then to do replacements for gitweb.cgi?Not all replacements are done in one or the other, and since it's basically a NOP to perform the full set of replacements on both files that seemed the easiest way to ensure they were done in both places.
Quoted 2 lines
Oh, I see there is at least one that stayed in gitweb.perl: $version
<snip>
O.K.
But Makefile would be (slightly) simpler if replacements were needed only for single file of two.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
.gitignore +6
-0+# Define and than setup our configuration +# +our( + $VERSION, + $path_info, + $GIT,
[...]
Quoted 10 lines
Quoted 7 lines
.gitignore
Quoted 4 lines
.gitignore +3
-0+ $prevent_xss, + @diff_opts, + %feature );Why this block is required? Why not have variables defined (using "our") in
gitweb_defaultsfile?Wanted to make sure things were properly defined, if in an unexpected state, should a user have gitweb.cgi in place but not the defaults.
In my opinion it actually *makes worse*. I am not sure if gitweb would work if the variables are undefined, and you would lose 'undeclared variable' warning.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
gitweb/gitweb_defaults.perl new file +0
-1--- /dev/null
Quoted 8 lines
Quoted 8 lines
gitweb/gitweb_defaults.perl line 6
Quoted 8 lines
+++ b/gitweb/gitweb_defaults.perl
gitweb/gitweb_defaults.perl new file +6
-0@@ -0,0 +1,468 @@ +# gitweb - simple web interface to track changes in git repositories +# +# (C) 2005-2006, Kay Sievers <[email protected]> +# (C) 2005, Christian Gierke +# +# This program is licensed under the GPLv2
This header should probably be modified, at least stating what the file is for.
Quoted 8 lines
Quoted 6 lines
gitweb/gitweb_defaults.perl line 10
Quoted 4 lines
gitweb/gitweb_defaults.perl new file +4
-0+ +# Base URL for relative URLs in gitweb ($logo, $favicon, ...), +# needed and used only for URLs with nonempty PATH_INFO +$base_url = $my_url;Why not "our $base_url = $my_url;"?
same reason as the other 'our' includes above,
See comment above about pre-declaring variables actually making it worse wrt checking.
Quoted 2 lines
though why this ended up
as a separate patch vs. the rest of the file I don't know.
Errr... what you are talking about here?
Signature · 2 lines
Jakub Narebski Poland
Re: [PATCH 6/6] GITWEB - Separate defaults from main file
Quoted 15 lines · Jakub Narebski
Quoted 6 lines · J.H.
Quoted 6 lines
Quoted 5 lines
This is also a not-so-subtle start of trying to break up gitweb into separate files for easier maintainability, having everything in a single file is just a mess and makes the whole thing more complicated than it needs to be. This is a bit of a baby step towards breaking it up for easier maintenance.
Quoted 6 lines
Quoted 2 lines
The question is if easier maintenance and development by spliting gitweb for developers offsets ease of install for users.
This would just get dropped into the same location that gitweb.cgi exists in, there is no real difference in installation, and thus I can't see this as an issue for users.
Quoted 6 lines
To be more exact you have to know that you have to drop
_generatedfiles_, which means (for this version of patch) gitweb.cgi and gitweb_defaults.pl (or whatever the generated file with config variables would be named).ATTENTION!
You didn't have to shout.
Any progress on this front?
Not that I am anxious to queue new topics to 'next' right now (we are frozen for 1.6.6), but I think having what is proven to work well at a real site like k.org is much better than waiting for an unproven reimplementation using somebody else's framework only for your theoretical cleanliness. John has better things to do than doing such a rewrite himself, and even if you helped the process by producing a competing caching scheme based on existing web caching engines, the aggregated result (not just the web caching engine you base your work on) needs to get a similar field exposure to prove itself that it can scale to the load k.org sees, which would be quite a lot of work, no?
Re: [PATCH 6/6] GITWEB - Separate defaults from main file
Quoted 10 lines · Junio C Hamano
Not that I am anxious to queue new topics to 'next' right now (we are frozen for 1.6.6), but I think having what is proven to work well at a real site like k.org is much better than waiting for an unproven reimplementation using somebody else's framework only for your theoretical cleanliness. John has better things to do than doing such a rewrite himself, and even if you helped the process by producing a competing caching scheme based on existing web caching engines, the aggregated result (not just the web caching engine you base your work on) needs to get a similar field exposure to prove itself that it can scale to the load k.org sees, which would be quite a lot of work, no?
I'm not against (well, not much against) custom caching that kernel.org uses, but I am against large change to gitweb code currently accompanying caching, namely gather then output solution, which would negatively affect performance when caching is turned off.
Also I'd like to have caching code (the one that didn't made it to git mailing list for some reason, probably vger anti-SPAM filter) cleaned up for submission: remove commented-out code, reduce code duplication, separate dealing with orthogonal issues (cache itself, adaptivity of cache, background generation and 'in progress' info, generating key for cache (and improve key generation to include path_info / use %input_params)), follow the same style that gitweb itself uses.
As for the "[PATCH 6/6] GITWEB - Separate defaults from main file" patch, it would require modifying gitweb tests to use generated gitweb/gitweb.cgi rather than source gitweb/gitweb.perl.
As for having caching code tested by git.kernel.org: IIRC there was issue with it not having cache expiration thus gathering GB of cached data.
Signature · 2 lines
Jakub Narebski Poland
Re: [PATCH 6/6] GITWEB - Separate defaults from main file
In reply to Junio C HamanoQuoted 17 lines · Junio C Hamano
Quoted 15 lines · Jakub Narebski
Quoted 8 lines · J.H.
Quoted 7 lines
Quoted 5 lines
This is also a not-so-subtle start of trying to break up gitweb into separate files for easier maintainability, having everything in a single file is just a mess and makes the whole thing more complicated than it needs to be. This is a bit of a baby step towards breaking it up for easier maintenance.
The question is if easier maintenance and development by spliting gitweb for developers offsets ease of install for users.
This would just get dropped into the same location that gitweb.cgi exists in, there is no real difference in installation, and thus I can't see this as an issue for users.
To be more exact you have to know that you have to drop
_generatedfiles_, which means (for this version of patch) gitweb.cgi and gitweb_defaults.pl (or whatever the generated file with config variables would be named).
Quoted 5 lines
Quoted 1 line
ATTENTION!
You didn't have to shout.
Any progress on this front?
Sadly, no. Busy weekend and a need to get some of the kernel.org servers upgraded has taken some precedence. I should be circling back around on this tomorrow I think.
Quoted 10 lines
Not that I am anxious to queue new topics to 'next' right now (we are frozen for 1.6.6), but I think having what is proven to work well at a real site like k.org is much better than waiting for an unproven reimplementation using somebody else's framework only for your theoretical cleanliness. John has better things to do than doing such a rewrite himself, and even if you helped the process by producing a competing caching scheme based on existing web caching engines, the aggregated result (not just the web caching engine you base your work on) needs to get a similar field exposure to prove itself that it can scale to the load k.org sees, which would be quite a lot of work, no?
Re: [PATCH 6/6] GITWEB - Separate defaults from main file
Quoted 7 lines · J.H.
Quoted 1 line · Junio C Hamano
Any progress on this front?
Sadly, no. Busy weekend and a need to get some of the kernel.org servers upgraded has taken some precedence. I should be circling back around on this tomorrow I think.
So should I wait for reroll with proposals for improvements (modified patches)?
Signature · 2 lines
Jakub Narebski Poland
Re: [PATCH 6/6] GITWEB - Separate defaults from main file
Quoted 7 lines · Jakub Narebski
Quoted 4 lines · J.H.
Quoted 1 line · Junio C Hamano
Any progress on this front?
Sadly, no. Busy weekend and a need to get some of the kernel.org servers upgraded has taken some precedence. I should be circling back around on this tomorrow I think.
So should I wait for reroll with proposals for improvements (modified patches)?
I'd probably wait, though it's starting to look like if I get to gitweb today it will be this evening as I ventured off into getting the last 6 of the kernel.org servers upgraded. Either way I will have a new patch series and some changes in my own git tree shortly.
- John 'Warthog9' Hawley
Re: [PATCH 4/6] GITWEB - Makefile changes
In reply to John 'Warthog9' Hawley"John 'Warthog9' Hawley" <[email protected]> writes:
Below are _proposed_ changes to make commit message easier to read, in my opinion. But they are not _necessary_ changes.
Quoted 1 line
This adjust the makefiles so that you can do such things as
Add "gitweb" target to main Makefile so you would be able to simply use
Quoted 4 lines
make gitweb
from the top level make tree,
instead of requiring to spell it in full
make gitweb/gitweb.cgi
Quoted 2 lines
or if your in the gitweb directory
itself typing
Add Makefile in gitweb subdirectory so one can simply run
Quoted 2 lines
make
when in gitweb subdirectory,
Quoted 4 lines
will call back up to the main
Makefileand build gitwebSigned-off-by John 'Warthog9' Hawley <[email protected]>
Signoff mismatch.
Quoted 5 lines
--- Makefile | 4 +++- gitweb/Makefile | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletions(-) create mode 100644 gitweb/Makefile
IMPORTANT!
A note about this change: I think it would be better to move creating gitweb.cgi (and optionally gitweb.min.js) to gitweb/Makefile, and make main Makefile call gitweb/Makefile, and not vice versa like in your solution.
If it is possible.
Makefile $(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl · line 1512
Quoted 9 lines
Makefile +1
-0@@ -1509,6 +1509,8 @@ $(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl chmod +x $@+ && \ mv $@+ $@ +.PHONY: gitweb
Why it is here, and not with the .PHONY block at line 1924 of Makefile? It would be nice to have comment supporting this choice in email with this patch (or in commit message).
Makefile endif · line 1542
Quoted 10 lines
Makefile +2
-1+gitweb: gitweb/gitweb.cgi ifdef JSMIN OTHER_PROGRAMS += gitweb/gitweb.cgi gitweb/gitweb.min.js gitweb/gitweb.cgi: gitweb/gitweb.perl gitweb/gitweb.min.js@@ -1537,7 +1539,7 @@ endif -e 's|++GITWEB_JS++|$(GITWEB_JS)|g' \ -e 's|++GITWEB_SITE_HEADER++|$(GITWEB_SITE_HEADER)|g' \ -e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g' \ - $< >$@+ && \ + $(patsubst %.cgi,%.perl,$@) >$@+ && \
Why this change?
gitweb/Makefile line 1
Quoted 10 lines
Makefile +0
-0chmod +x $@+ && \ mv $@+ $@gitweb/Makefile new file +1
-0@@ -0,0 +1,14 @@ +SHELL = /bin/bash
Why is this needed?
gitweb/Makefile line 5
Quoted 4 lines
gitweb/Makefile new file +4
-0+ +FILES = gitweb.cgi + +.PHONY: $(FILES)
Why .PHONY? $(FILES) are created.
Quoted 9 lines
gitweb/Makefile new file +9
-0+ +all: $(FILES) + +$(FILES): + $(MAKE) $(MFLAGS) -C ../ -f Makefile gitweb/$@ + +clean: + rm -rf $(FILES) +
Signature · 3 lines
Jakub Narebski Poland ShadeHawk on #git
Re: [PATCH 4/6] GITWEB - Makefile changes
<snip>
Quoted 8 lines
IMPORTANT!
A note about this change: I think it would be better to move creating gitweb.cgi (and optionally gitweb.min.js) to gitweb/Makefile, and make main
Makefilecall gitweb/Makefile, and not vice versa like in your solution.If it is possible.
It's quite possible, and I'm fine with doing that. If no one has any objections I can re-work those with the understanding that the build process for gitweb shift to the gitweb/ directory instead of the main Makefile.
Quoted 9 lines
Quoted 9 lines
Makefile +0
-0@@ -1509,6 +1509,8 @@ $(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl chmod +x $@+ && \ mv $@+ $@
Quoted 5 lines
Makefile $(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl · line 1512
Quoted 1 line
Makefile +1
-0+.PHONY: gitwebWhy it is here, and not with the .PHONY block at line 1924 of
Makefile? It would be nice to have comment supporting this choice in email with this patch (or in commit message).
There are 6 other instances of .PHONY in the makefile, having the .PHONY localized seemed to make it the most obvious since it was right next to the actual target.
Quoted 13 lines
Makefile endif · line 1542
Quoted 11 lines
Makefile +2
-1+gitweb: gitweb/gitweb.cgi ifdef JSMIN OTHER_PROGRAMS += gitweb/gitweb.cgi gitweb/gitweb.min.js gitweb/gitweb.cgi: gitweb/gitweb.perl gitweb/gitweb.min.js@@ -1537,7 +1539,7 @@ endif -e 's|++GITWEB_JS++|$(GITWEB_JS)|g' \ -e 's|++GITWEB_SITE_HEADER++|$(GITWEB_SITE_HEADER)|g' \ -e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g' \ - $< >$@+ && \ + $(patsubst %.cgi,%.perl,$@) >$@+ && \Why this change?
Preparation for a later change. The change could happen all at the same time if it makes more logical sense.
Quoted 14 lines
gitweb/Makefile line 1
Quoted 11 lines
Makefile +0
-0chmod +x $@+ && \ mv $@+ $@gitweb/Makefile new file +1
-0@@ -0,0 +1,14 @@ +SHELL = /bin/bashWhy is this needed?
Quoted 6 lines
gitweb/Makefile line 5
Quoted 4 lines
gitweb/Makefile new file +4
-0+ +FILES = gitweb.cgi + +.PHONY: $(FILES)Why .PHONY? $(FILES) are created.
From this makefile I wanted to explicitly call up to the main makefile no matter what, the main makefile doesn't consider the targets .PHONY and it has all the dependencies that it would expect.
Quoted 9 lines
Quoted 9 lines
gitweb/Makefile new file +9
-0+ +all: $(FILES) + +$(FILES): + $(MAKE) $(MFLAGS) -C ../ -f Makefile gitweb/$@ + +clean: + rm -rf $(FILES) +
Re: [PATCH 4/6] GITWEB - Makefile changes
Quoted 7 lines · J.H.
Quoted 7 lines
IMPORTANT!
A note about this change: I think it would be better to move creating gitweb.cgi (and optionally gitweb.min.js) to gitweb/Makefile, and make main
Makefilecall gitweb/Makefile, and not vice versa like in your solution.
Quoted 6 lines
Quoted 1 line
If it is possible.
It's quite possible, and I'm fine with doing that. If no one has any objections I can re-work those with the understanding that the build process for gitweb shift to the gitweb/ directory instead of the main
Makefile.
In my opinion it would be better solution because it would reduce size of main (master) Makefile, and not be much larger than this solution.
git-gui/, Documentation/, perl/ all have their own makefiles, which do the work, and are called from main (master) Makefile.
Quoted 14 lines
Quoted 8 lines
Quoted 8 lines
Makefile +0
-0@@ -1509,6 +1509,8 @@ $(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl chmod +x $@+ && \ mv $@+ $@Quoted 5 lines
Makefile $(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl · line 1512
Quoted 1 line
Makefile +1
-0+.PHONY: gitwebWhy it is here, and not with the .PHONY block at line 1924 of
Makefile? It would be nice to have comment supporting this choice in email with this patch (or in commit message).
Quoted 3 lines
There are 6 other instances of .PHONY in the makefile, having the .PHONY localized seemed to make it the most obvious since it was right next to the actual target.
I was thinking here about this large block of .PHONY declarations, the one which is not inside conditional.
Quoted 13 lines
Quoted 4 lines
Quoted 4 lines
Makefile +1
-0+gitweb: gitweb/gitweb.cgi ifdef JSMIN OTHER_PROGRAMS += gitweb/gitweb.cgi gitweb/gitweb.min.js gitweb/gitweb.cgi: gitweb/gitweb.perl gitweb/gitweb.min.jsQuoted 8 lines
Makefile endif · line 1542
Quoted 6 lines
Makefile +1
-1@@ -1537,7 +1539,7 @@ endif -e 's|++GITWEB_JS++|$(GITWEB_JS)|g' \ -e 's|++GITWEB_SITE_HEADER++|$(GITWEB_SITE_HEADER)|g' \ -e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g' \ - $< >$@+ && \ + $(patsubst %.cgi,%.perl,$@) >$@+ && \Why this change?
Quoted 2 lines
Preparation for a later change. The change could happen all at the same time if it makes more logical sense.
Please at least describe this change in commit message.
But I think it could be moved to other patch, or put in separate patch. This change has nothing to do with easier gitweb generation.
Quoted 12 lines
Quoted 12 lines
gitweb/Makefile line 1
Quoted 10 lines
Makefile +0
-0chmod +x $@+ && \ mv $@+ $@gitweb/Makefile new file +1
-0@@ -0,0 +1,14 @@ +SHELL = /bin/bashWhy is this needed?
Why do you need to define SHELL?
Quoted 10 lines
Quoted 6 lines
gitweb/Makefile line 5
Quoted 4 lines
gitweb/Makefile new file +4
-0+ +FILES = gitweb.cgi + +.PHONY: $(FILES)Why .PHONY? $(FILES) are created.
From this makefile I wanted to explicitly call up to the main makefile
no matter what, the main makefile doesn't consider the targets .PHONY and it has all the dependencies that it would expect.
What is the reason of this phony .PHONY? If gitweb.cgi is newer than gitweb.perl (and other sources), then without .PHONY it wouldn't be regenerated. With .PHONY it would call master Makefile... which would notice that gitweb.cgi is newer than gitweb.perl and do not regenerate.
So what this .PHONY does is unnecessary call make on master Makefile...
But I guess this issue would be moot if it was the other way around, i.e. master Makefile calling gitweb/Makefile.
Signature · 2 lines
Jakub Narebski Poland
PATCH 4/6 gitweb: Makefile improvements
From: John 'Warthog9' Hawley <[email protected]>
This commit adjust the main Makefile so you can simply run
make gitweb
which in turn calls gitweb/Makefile. This means that in order to generate gitweb, you can simply run 'make' from gitweb subdirectory:
cd gitweb
make
Targets gitweb/gitweb.cgi and (dependent on JSMIN being defined) gitweb/gitweb.min.js in main Makefile are preserved for backward compatibility.
---
This implements separate Makefile for gitweb, with main Makefile calling it, like for gitk-git/, git-gui/, Documentation/, t/, and templates/ directories.
It is marked as RFC because I don't feel that my make-fu is strong enough to be sure that there are no errors / mistakes. Very slightly tested.
Makefile | 64 +++++---------------------- gitweb/Makefile | 129 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 141 insertions(+), 52 deletions(-) create mode 100644 gitweb/Makefile
Makefile +12 -52
@@ -280,29 +280,6 @@ pathsep = : # JavaScript minifier invocation that can function as filter JSMIN = -# default configuration for gitweb -GITWEB_CONFIG = gitweb_config.perl -GITWEB_CONFIG_SYSTEM = /etc/gitweb.conf -GITWEB_HOME_LINK_STR = projects -GITWEB_SITENAME = -GITWEB_PROJECTROOT = /pub/git -GITWEB_PROJECT_MAXDEPTH = 2007 -GITWEB_EXPORT_OK = -GITWEB_STRICT_EXPORT = -GITWEB_BASE_URL = -GITWEB_LIST = -GITWEB_HOMETEXT = indextext.html -GITWEB_CSS = gitweb.css -GITWEB_LOGO = git-logo.png -GITWEB_FAVICON = git-favicon.png -ifdef JSMIN -GITWEB_JS = gitweb.min.js -else -GITWEB_JS = gitweb.js -endif -GITWEB_SITE_HEADER = -GITWEB_SITE_FOOTER = - export prefix bindir sharedir sysconfdir CC = gcc
@@ -1509,6 +1486,11 @@ $(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl chmod +x $@+ && \ mv $@+ $@ + +.PHONY: gitweb +gitweb: + $(QUIET_SUBDIR0)gitweb $(QUIET_SUBDIR1) all + ifdef JSMIN OTHER_PROGRAMS += gitweb/gitweb.cgi gitweb/gitweb.min.js gitweb/gitweb.cgi: gitweb/gitweb.perl gitweb/gitweb.min.js
@@ -1516,30 +1498,13 @@ else OTHER_PROGRAMS += gitweb/gitweb.cgi gitweb/gitweb.cgi: gitweb/gitweb.perl endif - $(QUIET_GEN)$(RM) $@ $@+ && \ - sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \ - -e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \ - -e 's|++GIT_BINDIR++|$(bindir)|g' \ - -e 's|++GITWEB_CONFIG++|$(GITWEB_CONFIG)|g' \ - -e 's|++GITWEB_CONFIG_SYSTEM++|$(GITWEB_CONFIG_SYSTEM)|g' \ - -e 's|++GITWEB_HOME_LINK_STR++|$(GITWEB_HOME_LINK_STR)|g' \ - -e 's|++GITWEB_SITENAME++|$(GITWEB_SITENAME)|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_STRICT_EXPORT++|$(GITWEB_STRICT_EXPORT)|g' \ - -e 's|++GITWEB_BASE_URL++|$(GITWEB_BASE_URL)|g' \ - -e 's|++GITWEB_LIST++|$(GITWEB_LIST)|g' \ - -e 's|++GITWEB_HOMETEXT++|$(GITWEB_HOMETEXT)|g' \ - -e 's|++GITWEB_CSS++|$(GITWEB_CSS)|g' \ - -e 's|++GITWEB_LOGO++|$(GITWEB_LOGO)|g' \ - -e 's|++GITWEB_FAVICON++|$(GITWEB_FAVICON)|g' \ - -e 's|++GITWEB_JS++|$(GITWEB_JS)|g' \ - -e 's|++GITWEB_SITE_HEADER++|$(GITWEB_SITE_HEADER)|g' \ - -e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g' \ - $< >$@+ && \ - chmod +x $@+ && \ - mv $@+ $@ + $(QUIET_SUBDIR0)gitweb $(QUIET_SUBDIR1) $(patsubst gitweb/%,%,$@) + +ifdef JSMIN +gitweb/gitweb.min.js: gitweb/gitweb.js + $(QUIET_SUBDIR0)gitweb $(QUIET_SUBDIR1) $(patsubst gitweb/%,%,$@) +endif # JSMIN + git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css gitweb/gitweb.js $(QUIET_GEN)$(RM) $@ $@+ && \
@@ -1566,11 +1531,6 @@ $(patsubst %.perl,%,$(SCRIPT_PERL)) git-instaweb: % : unimplemented.sh mv $@+ $@ endif # NO_PERL -ifdef JSMIN -gitweb/gitweb.min.js: gitweb/gitweb.js - $(QUIET_GEN)$(JSMIN) <$< >$@ -endif # JSMIN - configure: configure.ac $(QUIET_GEN)$(RM) $@ $<+ && \ sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
gitweb/Makefile new file +129 -0
129 lines not on this page · raw message
Signature · 1 line
1.6.5.3
Re: [PATCH 3/6] GITWEB - Add git:// link to summary pages
In reply to John 'Warthog9' HawleyHi,
Quoted 2 lines · On Thu, 10 Dec 2009, John 'Warthog9' Hawley wrote:
This adds a
git://link to the summary pages should a common $gitlinkurl be defined (default is nothing defined, thus nothing shown)
Nice.
I forgot to mention in my comments to 2/6 that you seem to wrap after more than 80 characters. However, I have no idea what the suggested line width is for gitweb.
Again, this could be done by having the variable defined as undef.
Maybe it would be even nicer if the administrator could specify the protocol, e.g. when they do not want/cannot allow git:// but only http://
access to the repositories?
Ciao,
Dscho
Re: [PATCH 3/6] GITWEB - Add git:// link to summary pages
In reply to John 'Warthog9' HawleyQuoted 6 lines · "John 'Warthog9' Hawley" <[email protected]> writes:
This adds a
git://link to the summary pages should a common $gitlinkurl be defined (default is nothing defined, thus nothing shown)This does make the assumption that the git trees share a common path, and nothing to date is known to actually make use of the link
The problem I had and have with this patch is the duplication of data:
$gitlinkurl contains subset of information in @git_base_url_list, which in turn is filled from GITWEB_BASE_URL build config variable.
I can understand that for performance reason you don't want to check $projectroot/$project/cloneurl nor gitweb.url config variable for each and every displayed project; if the link to repository (for git) cannot be derived from project path (repository path), then simply do not dosplay it.
Quoted 12 lines
Signed-off-by John 'Warthog9' Hawley <[email protected]>--- gitweb/gitweb.perl | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)gitweb/gitweb.perl +0
-0
gitweb/gitweb.perl our %avatar_size = ( · line 228
Quoted 5 lines
gitweb/gitweb.perl +2
-0@@ -224,6 +224,10 @@ our %avatar_size = ( # This is here to allow for missmatch git & gitweb versions our $missmatch_git = ''; +#This is here to deal with an extra link on the summary pages - if it's left blank +# this link will not be shwon. If it's set, this will be prepended to the repo and used
s/shwon/shown/
I'd say that 'Full URL is "$gitlinkurl/$project"' instead of last sentence in above comment.
Please watch for excessive line lengths.
gitweb/gitweb.perl our %avatar_size = ( · line 229
Quoted 1 line
gitweb/gitweb.perl +1
-0+our $gitlinkurl = '';
Why not
our $gitlinkurl_base = "++GITWEB_BASE_URL++";
of course changing the name everywhere.
gitweb/gitweb.perl sub git_project_list_body { · line 4464
Quoted 12 lines
gitweb/gitweb.perl +5
-0+ # Used to set the maximum load that we will still respond to gitweb queries. # if we exceed this than we do the processing to figure out if there's a mirror # and redirect to it, or to just return 503 server busy@@ -4454,6 +4458,10 @@ sub git_project_list_body { $cgi->a({-href => href(project=>$pr->{'path'}, action=>"log")}, "log") . " | " . $cgi->a({-href => href(project=>$pr->{'path'}, action=>"tree")}, "tree") . ($pr->{'forks'} ? " | " . $cgi->a({-href => href(project=>$pr->{'path'}, action=>"forks")}, "forks") : '') . + if( $gitlinkurl ne '' ){ + print " | ". $cgi->a({-href => "git://$gitlinkurl/".esc_html($pr->{'path'})}, "git"); + } + print "".
Does it even pass tests?
$cgi->a({-href => href(project=>$pr->{'path'}, action=>"log")}, "log") . " | " . $cgi->a({-href => href(project=>$pr->{'path'}, action=>"tree")}, "tree") . ($pr->{'forks'} ? " | " . $cgi->a({-href => href(project=>$pr->{'path'}, action=>"forks")}, "forks") : '') .
+ ($gitlinkurl_base ?
+ " | " . $cgi->a({-href=>"$gitlinkurl_base/$pr->{'path'}", "git") : '') .
"</td>\n" .
"</tr>\n";
}
Changes made:
* Instead of using separate if conditional statement and print statement (note that you forgot to change '.' to ';' to end statement) use ternary conditional operator "?:"
* Make $gitlinkurl_base include "git://" protocol specifier
* Do not create "git" link if $gitlinkurl_base is false, which means undef, empty string '' and 0 (but 0 is not very likely to be base for "git" link).
* Do not use esc_html on fragment of URL. The CGI.pm should escape attributes itself. If it was HTTP link, one should perhaps esc_url on whole link, but esc_html is for escaping HTML.
Signature · 3 lines
Jakub Narebski Poland ShadeHawk on #git
PATCH v2 3/6 gitweb: Optionally add "git" links in project list page
From: John 'Warthog9' Hawley <[email protected]>
This adds a "git" link for each project in the project list page, should a common $gitlinkurl_base be defined and not empty. The full URL of each link is composed of $gitlinkurl_base and project name. It is intended for git:// links, and in fact GITWEB_BASE_URL build variable is used as its default value only if it starts with git://
This does make the assumption that the git repositories share a common path. Nothing to date is known to actually make use of introduced link.
Created "git" link follows rel=vcs-* microformat specification:
http://kitenet.net/~joey/rfc/rel-vcs/
---
I think it might be good idea... but for the fact "Nothing to date is known to actually make use of introduced link". What's its intended use?
Differences to original version by John 'Warthog9' Hawley (J.H.):
* It doesn't cause syntax error ;-)
* Escaping of attribute value is left to CGI.pm
* $gitlinkurl got renamed to $gitlinkurl_base, now includes git://
prefix, and defaults to GITWEB_BASE_URL if it begins with git://
* Added description to gitweb/README
* Uses rel=vcs-* microformat by Joey Hess
I assume that nobody sane would define $gitlinkurl_base to "0"...
gitweb/README | 4 ++++ gitweb/gitweb.perl | 8 ++++++++ 2 files changed, 12 insertions(+), 0 deletions(-)
gitweb/README +4 -0
@@ -71,6 +71,7 @@ You can specify the following configuration variables when building GIT: * GITWEB_BASE_URL Git base URLs used for URL to where fetch project from, i.e. full URL is "$git_base_url/$project". Shown on projects summary page. + If it begins with "git://" it is also used for $gitlinkurl_base, see below. Repository URL for project can be also configured per repository; this takes precedence over URLs composed from base URL and a project name. Note that you can setup multiple base URLs (for example one for
@@ -204,6 +205,9 @@ not include variables usually directly set during build): access, and one for http:// "dumb" protocol access). Note that per repository configuration in 'cloneurl' file, or as values of gitweb.url project config. + * $gitlinkurl_base + Git base URL used (if it is defined and not empty) for "git" link in + projects list, for each project. Full URL is "$gitlinkurl_base/$project". * $default_blob_plain_mimetype Default mimetype for blob_plain (raw) view, if mimetype checking doesn't result in some other type; by default 'text/plain'.
gitweb/gitweb.perl +8 -0
@@ -224,6 +224,10 @@ our %avatar_size = ( # If it is true, exit if gitweb version and git binary version don't match our $git_versions_must_match = 0; +# If this variable is set and not empty, add an extra link called "git" +# for each project in project list. Full URL is "$gitlinkurl_base/$project". +our $gitlinkurl_base = ("++GITWEB_BASE_URL++" =~ m!^(git://.*)$!) ? $1 : ''; + # Used to set the maximum load that we will still respond to gitweb queries. # If server load exceed this value then return "503 server busy" error. # If gitweb cannot determined server load, it is taken to be 0.
@@ -4472,6 +4476,10 @@ sub git_project_list_body { $cgi->a({-href => href(project=>$pr->{'path'}, action=>"log")}, "log") . " | " . $cgi->a({-href => href(project=>$pr->{'path'}, action=>"tree")}, "tree") . ($pr->{'forks'} ? " | " . $cgi->a({-href => href(project=>$pr->{'path'}, action=>"forks")}, "forks") : '') . + ($gitlinkurl_base ? + " | " . $cgi->a({-href=>"$gitlinkurl_base/$pr->{'path'}", + -rel=>"vcs-git"}, "git") + : '') . "</td>\n" . "</tr>\n"; }
Signature · 1 line
1.6.5.3
Re: [PATCH 2/6] GITWEB - Missmatching git w/ gitweb
In reply to John 'Warthog9' HawleyHi,
Quoted 2 lines · On Thu, 10 Dec 2009, John 'Warthog9' Hawley wrote:
This adds $missmatch_git so that gitweb can run with a miss-matched git install.
I'm not a native English speaker and all, but I thought it was spelt 'mismatch', i.e. with only one 's'. Maybe even name it 'allow_different_git_version' or 'no_strict_git_version'.
A few comments on the patch: the style of the if() statement disagrees with the other ones; please use the same style.
Also, as with 1/6, turning off the feature might be better done by setting it to undef.
Finally, would it not be nicer if the warning really was only a warning, i.e. that the script would try to continue after giving the users a pretty warning header?
Ciao,
Dscho
Re: [PATCH 2/6] GITWEB - Missmatching git w/ gitweb
In reply to John 'Warthog9' HawleyQuoted 11 lines · "John 'Warthog9' Hawley" <[email protected]> writes:
This adds $missmatch_git so that gitweb can run with a miss-matched git install. Gitweb, generally, runs fine on a very broad range of git versions, but it's not always practicle or useful to upgrade it every time you upgrade git.
This allows the administrator to realize they are miss-matched, and should they be so inclined, disable the check entirely and run in a miss-matched fasion.
This is more here to give an obvious warning as to whats going on vs. silently failing.
First, why one would want to require that gitweb version (version at the time of build) and runtime git version (version of git used to run commands) match?
Second, it is mismatch, not missmatch (one 's', not double 's').
Third, in my opinion it would be better to name variable in question e.g. $versions_must_match and also flip its meaning (true means check that versions match, and show an error otherwise).
Quoted 2 lines
Signed-off-by John 'Warthog9' Hawley <[email protected]>
signoff mismatch
Quoted 10 lines
--- gitweb/gitweb.perl | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+), 0 deletions(-)gitweb/gitweb.perl +0
-0
gitweb/gitweb.perl our %avatar_size = ( · line 226
Quoted 6 lines
gitweb/gitweb.perl +3
-0@@ -221,6 +221,9 @@ our %avatar_size = ( 'double' => 32 ); +# This is here to allow for missmatch git & gitweb versions +our $missmatch_git = ''; +
First, 'undef' is false, so it could have been written as
+our $missmatch_git;
Or if you prefer explicit false-ish value as default, 0 would be I think better than empty string '':
+our $missmatch_git = 0;
Second, there is question whether default should be to allow mismatched versions (current behaviour, more lenient...) or deny (or warn about) mismatched version, i.e. should it be $versions_must_match false by default, or $allow_versions_mismatch false by default.
gitweb/gitweb.perl if (get_loadavg() > $maxload) { · line 588
Quoted 11 lines
gitweb/gitweb.perl +4
-0# Used to set the maximum load that we will still respond to gitweb queries. # if we exceed this than we do the processing to figure out if there's a mirror # and redirect to it, or to just return 503 server busy@@ -579,6 +582,25 @@ if (get_loadavg() > $maxload) { our $git_version = qx("$GIT" --version) =~ m/git version (.*)$/ ? $1 : "unknown"; $number_of_git_cmds++; +# There's a pretty serious flaw that we silently fail if git doesn't find something it needs +# a quick and simple check is to have gitweb do a simple check - are we running on the same +# version of git that we shipped with - if not, throw up an error so that people doing +# first installs don't have to debug perl to figure out whats going on
Could you please clean up language in above comment? It is very convoluted. Please also limit line width of above comment to 76 / 80 columns.
gitweb/gitweb.perl if (get_loadavg() > $maxload) { · line 593
Quoted 5 lines
gitweb/gitweb.perl +5
-0+if ( + $git_version ne $version + && + $missmatch_git eq '' +){
Style
+if (!$allow_versions_mismatch &&
+ $git_version ne $version) {
Do not compare $missmatch_git / $allow_versions_mismatch against '':
it is a boolean value!
gitweb/gitweb.perl if (get_loadavg() > $maxload) { · line 594
Quoted 1 line
gitweb/gitweb.perl +1
-0+ git_header_html();
Shouldn't this be "500 Internal Server Error" or something (using the optional parameter to git_header_html())?
gitweb/gitweb.perl if (get_loadavg() > $maxload) { · line 598
Quoted 4 lines
gitweb/gitweb.perl +4
-0+ print "<p><b>*** Warning ***</b></p>\n"; + print "<p>\n"; + print "This version of gitweb was compiled for <b>$version</b> however git version <b>$git_version</b> was found<br/>\n"; + print "If you are sure this version of git works with this version of gitweb - please define <b>\$missmatch_git</b> to a non empty string in your git config file.\n";
Too long lines. Here-doc could be better here.
Quoted 8 lines
gitweb/gitweb.perl +5
-0+ print "</p>\n"; + git_footer_html(); + exit; +} + $projects_list ||= $projectroot; # ======================================================================
Signature · 3 lines
Jakub Narebski Poland ShadeHawk on #git
PATCH 2/6 gitweb: Add option to force version match
From: John 'Warthog9' Hawley <[email protected]>
This adds $git_versions_must_match variable, which is set to true value checks that we are running on the same version of git that we shipped with, and if not throw '500 Internal Server Error' error. What is checked is the version of gitweb (embedded in building gitweb.cgi), against version of runtime git binary used.
Gitweb can usually run with a mismatched git install. This is more here to give an obvious warning as to whats going on vs. silently failing.
By default this feature is turned off.
---
I don't quite see the reason behind such option, and I think that error (instead of for example warning) on version mismatch is too much.
This is an RFC because formatting of error page is a bit rough, and (ab)uses exist CSS classes instead of creating new classnames for semantic markup.
Differences from original version, by J.H.:
* Changed name and flipped meaning of config variable, from $missmatch_git to $git_versions_must_match
* $git_versions_must_match is boolean flag - do not compare with an empty string.
* Changed error message a bit, fixed style, added entry in README
gitweb/README | 3 +++ gitweb/gitweb.perl | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 0 deletions(-)
gitweb/README +3 -0
@@ -233,6 +233,9 @@ not include variables usually directly set during build): If server load exceed this value then return "503 Service Unavaliable" error. Server load is taken to be 0 if gitweb cannot determine its value. Set it to undefined value to turn it off. The default is 300. + * $git_versions_must_match + If set, gitweb fails with 500 Internal Server Error if the version of gitweb + doesn't match version of git binary. The default is false. Projects list file format
gitweb/gitweb.perl +33 -0
@@ -221,6 +221,9 @@ our %avatar_size = ( 'double' => 32 ); +# If it is true, exit if gitweb version and git binary version don't match +our $git_versions_must_match = 0; + # Used to set the maximum load that we will still respond to gitweb queries. # If server load exceed this value then return "503 server busy" error. # If gitweb cannot determined server load, it is taken to be 0.
@@ -581,6 +584,36 @@ if (defined $maxload && get_loadavg() > $maxload) { our $git_version = qx("$GIT" --version) =~ m/git version (.*)$/ ? $1 : "unknown"; $number_of_git_cmds++; +# Throw an error if git versions does not match, if $git_versions_must_match is true. +if ($git_versions_must_match && + $git_version ne $version) { + git_header_html('500 - Internal Server Error'); + my $admin_contact = + defined $ENV{'SERVER_ADMIN'} ? ", $ENV{'SERVER_ADMIN'}," : ''; + print <<"EOT"; +<div class="page_body"> +<br /><br /> +500 - Internal Server Error +<br /> +</div> +<hr /> +<div class="readme"> +<h1 align="center">*** Warning ***</h1> +<p> +This version of gitweb was compiled for <b>@{[esc_html($version)]}</b>, +however git version <b>@{[esc_html($git_version)]}</b> was found on server, +and administrator requested strict version checking. +</p> +<p> +Please contact the server administrator${admin_contact} to either configure +gitweb to allow mismatched versions, or update git or gitweb installation. +</p> +</div> +EOT + git_footer_html(); + exit; +} + $projects_list ||= $projectroot; # ======================================================================
Signature · 1 line
1.6.5.3
Re: [PATCH 1/6] GITWEB - Load Checking
In reply to John 'Warthog9' HawleyQuoted 2 lines
"John 'Warthog9' Hawley" <[email protected]> :
+open($load, '<', '/proc/loadavg')or return 0;
What about systems not having /proc/loadavg
Signature · 3 lines
Architecte Informatique chez Blueline/Gulfsat:
Administration Systeme, Recherche & Developpement
+261 34 29 155 34 / +261 33 11 207 36Re: [PATCH 1/6] GITWEB - Load Checking
In reply to John 'Warthog9' HawleyHeya,
Quoted 4 lines · On Fri, Dec 11, 2009 at 00:45, John 'Warthog9' Hawley <[email protected]>…
gitweb/gitweb.perl | 24 ++++++++++++++++++++++++
1 files changed, 24 insertions(+), 0 deletions(-)
Also, what happened to including patches inline for ease of review?
Signature · 3 lines
Cheers, Sverre Rabbelier
Re: [PATCH 1/6] GITWEB - Load Checking
In reply to John 'Warthog9' HawleyQuoted 10 lines · "John 'Warthog9' Hawley" <[email protected]> writes:
This changes the behavior, slightly, of gitweb so that it verifies that the box isn't inundated with before attempting to serve gitweb. If the box is overloaded, it basically returns a 503 server unavailable until the load falls below the defined threshold. This helps dramatically if you have a box that's I/O bound, reaches a certain load and you don't want gitweb, the I/O hog that it is, increasing the pain the server is already undergoing.
adds $maxload configuration variable. Default is a load of 300, which for most cases should never be hit.
Your patch doesn't allow for *turning off* this feature. Reasonable solution would be to use 'undef' or negative number to turn off this check (this feature).
Quoted 4 lines
Please note this makes the assumption that
/proc/loadavgexists as there is no good way to read load averages on a great number of platforms [READ: Windows], or that it's reasonably accurate.
What about MacOS X, or FreeBSD, or OpenSolaris?
You should mention that it is intended that if gitweb cannot read load average (for example /proc/loadavg does not exist), then the feature is turned off, i.e. the check always succeeds. Which is reasonable.
Quoted 2 lines
Signed-off-by John 'Warthog9' Hawley <[email protected]>
Why signoff is different from author ([email protected])? Why this email for signoff? Just curious...
Quoted 3 lines
--- gitweb/gitweb.perl | 24 ++++++++++++++++++++++++ 1 files changed, 24 insertions(+), 0 deletions(-)
Please post patches inline, not as attachement.
gitweb/gitweb.perl our %avatar_size = ( · line 226
Quoted 11 lines
gitweb/gitweb.perl +3
-0@@ -221,6 +221,11 @@ our %avatar_size = ( 'double' => 32 ); +# Used to set the maximum load that we will still respond to gitweb queries. +# if we exceed this than we do the processing to figure out if there's a mirror +# and redirect to it, or to just return 503 server busy
I'd probably say:
+# Used to set the maximum load that we will still respond to gitweb queries. +# If server load exceed this value then return "503 server busy" error, +# (it is also possible to redirect to mirror, if it exists, instead).
Quoted 6 lines
gitweb/gitweb.perl +2
-0+our $maxload = 300; + # You define site-wide feature defaults here; override them with # $GITWEB_CONFIG as necessary. our %feature = (
gitweb/gitweb.perl if (-e $GITWEB_CONFIG) { · line 564
Quoted 9 lines
gitweb/gitweb.perl +6
-0@@ -551,6 +556,25 @@ if (-e $GITWEB_CONFIG) { do $GITWEB_CONFIG_SYSTEM if -e $GITWEB_CONFIG_SYSTEM; } +# loadavg throttle +sub get_loadavg() { + my $load; + my @loads; + + open($load, '<', '/proc/loadavg') or return 0;
Why not use one of existing CPAN modules: Sys::Info::Device::CPU, BSD::getloadavg, Sys::CpuLoad?
Style:
+ open (my $load, '<', '/proc/loadavg') or return 0;
and of course no "my $load" at beginning. Also perhaps $fh, or $loadfh instead of $load? But this is a minor nit.
gitweb/gitweb.perl if (-e $GITWEB_CONFIG) { · line 575
Quoted 11 lines
gitweb/gitweb.perl +11
-0+ @loads = split(/\s+/, scalar <$load>); + close($load); + return $loads[0]; +} + +if (get_loadavg() > $maxload) { + print "Content-Type: text/plain\n"; + print "Status: 503 Excessive load on server\n"; + print "\n"; + print "The load average on the server is too high\n"; + exit 0;
Why not use die_error subroutine? Is it to have generate absolutely minimal load, and that is why you do not use die_error(), or even $cgi->header()?
Wouldn't a better solution be to use here-doc syntax?
+ print <<'EOF';
+Content-Type: text/plain; charset=utf-8
+Status: 503 Excessive load on server
+
+The load average on the server is too high
+EOF
+ exit 0;
Quoted 5 lines
gitweb/gitweb.perl +2
-0+} + # version of the core git binary our $git_version = qx("$GIT" --version) =~ m/git version (.*)$/ ? $1 : "unknown"; $number_of_git_cmds++;
Signature · 3 lines
Jakub Narebski Poland ShadeHawk on #git
Re: [PATCH 1/6] GITWEB - Load Checking
<snip>
Quoted 6 lines
Quoted 2 lines
adds $maxload configuration variable. Default is a load of 300, which for most cases should never be hit.
Your patch doesn't allow for *turning off* this feature. Reasonable solution would be to use 'undef' or negative number to turn off this check (this feature).
Well there's the opposite argument that setting the number arbitrarily high, 4096 for instance would also in essence negate this (though I'll admit I've reached and exceeded those numbers before)
That said I agree, being able to turn this off needs to be added and will be shortly.
Quoted 5 lines
Quoted 3 lines
Please note this makes the assumption that
/proc/loadavgexists as there is no good way to read load averages on a great number of platforms [READ: Windows], or that it's reasonably accurate.What about MacOS X, or FreeBSD, or OpenSolaris?
Will comment on this further down
Quoted 3 lines
You should mention that it is intended that if gitweb cannot read load average (for example
/proc/loadavgdoes not exist), then the feature is turned off, i.e. the check always succeeds. Which is reasonable.
That's fine.
Quoted 5 lines
Quoted 2 lines
Signed-off-by John 'Warthog9' Hawley <[email protected]>Why signoff is different from author ([email protected])? Why this email for signoff? Just curious...
My bad, did the patches up on my laptop but had to send them out from kernel.org, thus the miss-match: I.E. user error.
<snip>
Quoted 9 lines
gitweb/gitweb.perl if (-e $GITWEB_CONFIG) { · line 564
Quoted 6 lines
gitweb/gitweb.perl +6
-0+# loadavg throttle +sub get_loadavg() { + my $load; + my @loads; + + open($load, '<', '/proc/loadavg') or return 0;Why not use one of existing CPAN modules:
Sys::Info::Device::CPU,BSD::getloadavg,Sys::CpuLoad?
Here's the fundamental problem:
Sys:Info:Device:CPU
Windows:
Using this method under Windows is not recommended since, the WMI interface will possibly take at least 2 seconds to complete the request.
BSD::getloadavg
While this more or less supports anything with a libc getloadavg (and thus might be the best one I've seen, I'll admit I didn't notice this one when I looked years ago) getting it to work on windows looks, exciting.
Sys::CpuLoad:
http://cpansearch.perl.org/src/CLINTDW/Sys-CpuLoad-0.03/README
Specifically:
- Currently FreeBSD and OpenBSD are supported.
- Wanted: HPUX 11.11 ...
- Todo: Win32 support
So this doesn't really buy me anything but, maybe, BSD support.
So at the end of the day, none of those really gets me a "useful" cross platform load checker (though like I said BSD::getloadavg looks to be the best of the ones you mentioned) and more or less Windows is going to lose this as a usable feature no matter what.
I think I'd almost rather set this up so that if it can't get something useful (I.E. /proc/loadavg is missing) it just skips past it as if the load was 0.
I might try out the BSD::getloadavg but I want to take a look and see if that's easily installed or not, if it's not it might be difficult to justify that as a dependency.
<snip>
Quoted 13 lines
gitweb/gitweb.perl if (-e $GITWEB_CONFIG) { · line 575
Quoted 6 lines
gitweb/gitweb.perl +6
-0+if (get_loadavg() > $maxload) { + print "Content-Type: text/plain\n"; + print "Status: 503 Excessive load on server\n"; + print "\n"; + print "The load average on the server is too high\n"; + exit 0;Why not use
die_errorsubroutine? Is it to have generate absolutely minimal load, and that is why you do not usedie_error(), or even $cgi->header()?Wouldn't a better solution be to use here-doc syntax?
Review
Quoted 7 lines
(quoted diff) +7
-0+ print <<'EOF'; +Content-Type: text/plain; charset=utf-8 +Status: 503 Excessive load on server + +The load average on the server is too high +EOF + exit 0;
It was intended to be the most minimal possible, mainly get in, get out.
Also not sure the die_error existed in gitweb when this was originally
written. Probably worth switching to it now since it's there either way, and I don't think using it would add enough overhead to matter.
- John 'Warthog9' Hawley
Re: [PATCH 1/6] GITWEB - Load Checking
Quoted 8 lines · J.H.
<snip>
Quoted 6 lines
Quoted 2 lines
adds $maxload configuration variable. Default is a load of 300, which for most cases should never be hit.
Your patch doesn't allow for *turning off* this feature. Reasonable solution would be to use 'undef' or negative number to turn off this check (this feature).
Quoted 6 lines
Well there's the opposite argument that setting the number arbitrarily high, 4096 for instance would also in essence negate this (though I'll admit I've reached and exceeded those numbers before)
That said I agree, being able to turn this off needs to be added and will be shortly.
Simplest solution would be to used 'undef' (undefined value) for "turned off", i.e.:
if (defined $maxload && get_loadavg() > $maxload) {Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Please note this makes the assumption that
/proc/loadavgexists as there is no good way to read load averages on a great number of platforms [READ: Windows], or that it's reasonably accurate.What about MacOS X, or FreeBSD, or OpenSolaris?
Will comment on this further down
I think it would be better to write in commit message that because finding load average is OS dependent, there is provided (sample) solution which uses /proc/loadavg and works (at least) on Linux. And that for platforms which do not have /proc/loadavg the feature is simply turned off (by the way of using load=0 if load cannot be determined).
Quoted 5 lines
Quoted 3 lines
You should mention that it is intended that if gitweb cannot read load average (for example
/proc/loadavgdoes not exist), then the feature is turned off, i.e. the check always succeeds. Which is reasonable.That's fine.
See above proposal. This information should be present in commit message, and perhaps maybe even as one-line comment above opening /proc/loadavg.
Quoted 38 lines
Quoted 9 lines
gitweb/gitweb.perl if (-e $GITWEB_CONFIG) { · line 564
Quoted 6 lines
gitweb/gitweb.perl +6
-0+# loadavg throttle +sub get_loadavg() { + my $load; + my @loads; + + open($load, '<', '/proc/loadavg') or return 0;Why not use one of existing CPAN modules:
Sys::Info::Device::CPU,BSD::getloadavg,Sys::CpuLoad?Here's the fundamental problem:
Sys:Info:Device:CPU
Windows:
Using this method under Windows is not recommended since, the WMI interface will possibly take at least 2 seconds to complete the request.
BSD::getloadavg
While this more or less supports anything with a libc getloadavg (and thus might be the best one I've seen, I'll admit I didn't notice this one when I looked years ago) getting it to work on windows looks, exciting.
Sys::CpuLoad:
http://cpansearch.perl.org/src/CLINTDW/Sys-CpuLoad-0.03/README
Specifically:
- Currently FreeBSD and OpenBSD are supported.
- Wanted: HPUX 11.11 ...
- Todo: Win32 supportSo this doesn't really buy me anything but, maybe, BSD support.
So at the end of the day, none of those really gets me a "useful" cross platform load checker (though like I said
BSD::getloadavglooks to be the best of the ones you mentioned) and more or less Windows is going to lose this as a usable feature no matter what.
Quoted 7 lines
I think I'd almost rather set this up so that if it can't get something useful (I.E.
/proc/loadavgis missing) it just skips past it as if the load was 0.I might try out the
BSD::getloadavgbut I want to take a look and see if that's easily installed or not, if it's not it might be difficult to justify that as a dependency.
After thinking about this a bit, now I don't think that it is terribly important. You *might* describe alternate approaches (roads not taken) in commit message, but requiring /proc/loadavg for the feature to work is fine for first patch (it makes patch simpler).
Quoted 23 lines
Quoted 13 lines
gitweb/gitweb.perl if (-e $GITWEB_CONFIG) { · line 575
Quoted 6 lines
gitweb/gitweb.perl +6
-0+if (get_loadavg()> $maxload) { + print "Content-Type: text/plain\n"; + print "Status: 503 Excessive load on server\n"; + print "\n"; + print "The load average on the server is too high\n"; + exit 0;Why not use
die_errorsubroutine? Is it to have generate absolutely minimal load, and that is why you do not usedie_error(), or even $cgi->header()?Wouldn't a better solution be to use here-doc syntax?
Review
Quoted 7 lines
(quoted diff) +7
-0+ print <<'EOF'; +Content-Type: text/plain; charset=utf-8 +Status: 503 Excessive load on server + +The load average on the server is too high +EOF + exit 0;It was intended to be the most minimal possible, mainly get in, get out.
Quoted 3 lines
Also not sure the
die_errorexisted in gitweb when this was originally
written. Probably worth switching to it now since it's there either way, and I don't think using it would add enough overhead to matter.
Well, if you are not worring excessively about overhead, then I think using die_error would be the best solution, as it would preserve look of gitweb. It would require extending die_error by 503 response, or rather %http_responses hash and comment above die_error.
Also I think that Status: should be before Content-Type: header (but probably it is not required by the standard).
Signature · 2 lines
Jakub Narebski Poland
PATCH v2 1/6 gitweb: Load checking
From: John 'Warthog9' Hawley <[email protected]>
This changes slightly the behavior of gitweb, so that it verifies that the box isn't inundated with before attempting to serve gitweb. If the box is overloaded, it basically returns a 503 Server Unavailable until the load falls below the defined threshold. This helps dramatically if you have a box that's I/O bound, reaches a certain load and you don't want gitweb, the I/O hog that it is, increasing the pain the server is already undergoing.
This behavior is controlled by $maxload configuration variable. Default is a load of 300, which for most cases should never be hit. Unset it (set it to undefined value, i.e. undef) to turn off checking.
Currently it requires that '/proc/loadavg' file exists, otherwise the load check is bypassed (load is taken to be 0). So platforms that do not implement '/proc/loadavg' currently cannot use this feature.
---
This is my take on this patch, with all my concerns taken into consideration... well, all except describing alterante approaches to straight using /proc/loadavg.
Differences to original version by John 'Warthog9' Hawley (J.H.):
* Slightly improved wording in commit message and in comments
* $maxload described in gitweb/README, in "Gitweb config file variables" section
* You can use '$maxload = undef;' to turn off load checking
* Error page for too high load is generated using die_error, which had to be extended to handle 503 Service Unavailable HTTP error code
gitweb/README | 7 ++++++- gitweb/gitweb.perl | 39 +++++++++++++++++++++++++++++++++++---- 2 files changed, 41 insertions(+), 5 deletions(-)
gitweb/README +6 -1
@@ -174,7 +174,7 @@ not include variables usually directly set during build): Base URL for relative URLs in pages generated by gitweb, (e.g. $logo, $favicon, @stylesheets if they are relative URLs), needed and used only for URLs with nonempty PATH_INFO via - <base href="$base_url>. Usually gitweb sets its value correctly, + <base href="$base_url">. Usually gitweb sets its value correctly, and there is no need to set this variable, e.g. to $my_uri or "/". * $home_link Target of the home link on top of all pages (the first part of view
@@ -228,6 +228,11 @@ not include variables usually directly set during build): repositories from launching cross-site scripting (XSS) attacks. Set this to true if you don't trust the content of your repositories. The default is false. + * $maxload + Used to set the maximum load that we will still respond to gitweb queries. + If server load exceed this value then return "503 Service Unavaliable" error. + Server load is taken to be 0 if gitweb cannot determine its value. Set it to + undefined value to turn it off. The default is 300. Projects list file format
gitweb/gitweb.perl +35 -4
@@ -221,6 +221,12 @@ our %avatar_size = ( 'double' => 32 ); +# Used to set the maximum load that we will still respond to gitweb queries. +# If server load exceed this value then return "503 server busy" error. +# If gitweb cannot determined server load, it is taken to be 0. +# Leave it undefined (or set to 'undef') to turn off load checking. +our $maxload = 300; + # You define site-wide feature defaults here; override them with # $GITWEB_CONFIG as necessary. our %feature = (
@@ -551,6 +557,26 @@ if (-e $GITWEB_CONFIG) { do $GITWEB_CONFIG_SYSTEM if -e $GITWEB_CONFIG_SYSTEM; } +# Get loadavg of system, to compare against $maxload. +# Currently it requires '/proc/loadavg' present to get loadavg; +# if it is not present it returns 0, which means no load checking. +sub get_loadavg { + open my $fd, '<', '/proc/loadavg' + or return 0; + my @load = split(/\s+/, scalar <$fd>); + close $fd; + + # The first three columns measure CPU and IO utilization of the last one, + # five, and 10 minute periods. The fourth column shows the number of + # currently running processes and the total number of processes in the m/n + # format. The last column displays the last process ID used. + return $load[0] || 0; +} + +if (defined $maxload && get_loadavg() > $maxload) { + die_error(503, "The load average on the server is too high"); +} + # version of the core git binary our $git_version = qx("$GIT" --version) =~ m/git version (.*)$/ ? $1 : "unknown"; $number_of_git_cmds++;
@@ -3354,14 +3380,19 @@ sub git_footer_html { # 500: The server isn't configured properly, or # an internal error occurred (e.g. failed assertions caused by bugs), or # an unknown error occurred (e.g. the git binary died unexpectedly). +# 503: The server is currently unavailable (because it is overloaded, +# or down for maintenance). Generally, this is a temporary state. sub die_error { my $status = shift || 500; my $error = shift || "Internal server error"; - my %http_responses = (400 => '400 Bad Request', - 403 => '403 Forbidden', - 404 => '404 Not Found', - 500 => '500 Internal Server Error'); + my %http_responses = ( + 400 => '400 Bad Request', + 403 => '403 Forbidden', + 404 => '404 Not Found', + 500 => '500 Internal Server Error', + 503 => '503 Service Unavailable', + ); git_header_html($http_responses{$status}); print <<EOF; <div class="page_body">
Signature · 1 line
1.6.5.3
Re: [PATCH 1/6] GITWEB - Load Checking
In reply to J.H.Quoted 5 lines · J.H.
It was intended to be the most minimal possible, mainly get in, get out. Also not sure the
die_errorexisted in gitweb when this was originally written. Probably worth switching to it now since it's there either way, and I don't think using it would add enough overhead to matter.
Thanks; all sounded a reasonable response to the review. Are you re-rolling the series anytime soon (I am asking because then I'd rather not to queue this round especially because I didn't see 5/6).
Re: [PATCH 1/6] GITWEB - Load Checking
Quoted 11 lines · Junio C Hamano
Quoted 5 lines · J.H.
It was intended to be the most minimal possible, mainly get in, get out. Also not sure the
die_errorexisted in gitweb when this was originally written. Probably worth switching to it now since it's there either way, and I don't think using it would add enough overhead to matter.Thanks; all sounded a reasonable response to the review. Are you re-rolling the series anytime soon (I am asking because then I'd rather not to queue this round especially because I didn't see 5/6).
I'll probably have some changes up and about tomorrow, and it's a little troubling that 5/6 didn't come through for you
6 at least made it to marc.info: http://marc.info/?l=git&m=126048884825985&w=2
and 5 seems to have been eaten by a grue somewhere. It was a *big* patch mainly because all the caching flips over in a single go. If you want I can privately bounce 5 & 6 to you so you have a complete tree right now?
- John 'Warthog9' Hawley
Re: [PATCH 1/6] GITWEB - Load Checking
Quoted 13 lines · J.H.
Quoted 11 lines · Junio C Hamano
Quoted 5 lines · J.H.
It was intended to be the most minimal possible, mainly get in, get out. Also not sure the
die_errorexisted in gitweb when this was originally written. Probably worth switching to it now since it's there either way, and I don't think using it would add enough overhead to matter.Thanks; all sounded a reasonable response to the review. Are you re-rolling the series anytime soon (I am asking because then I'd rather not to queue this round especially because I didn't see 5/6).
Quoted 5 lines
I'll probably have some changes up and about tomorrow, and it's a little troubling that 5/6 didn't come through for you
6 at least made it to marc.info: http://marc.info/?l=git&m=126048884825985&w=2
and 5 seems to have been eaten by a grue somewhere. It was a *big* patch mainly because all the caching flips over in a single go. If you want I can privately bounce 5 & 6 to you so you have a complete tree right now?
Not to reply to myself but this might also be helpful:
http://git.kernel.org/?p=git/warthog9/gitweb.git;a=shortlog;h=refs/heads/gitweb-ml-v2
- John 'Warthog9' Hawley
Re: [PATCH 1/6] GITWEB - Load Checking
In reply to J.H.Quoted 9 lines · J.H.
Quoted 3 lines
Thanks; all sounded a reasonable response to the review. Are you re-rolling the series anytime soon (I am asking because then I'd rather not to queue this round especially because I didn't see 5/6).
I'll probably have some changes up and about tomorrow, and it's a little troubling that 5/6 didn't come through for you
6 at least made it to marc.info:
http://marc.info/?l=git&m=126048884825985&w=2
Sorry; I meant to say "[PATCH 5/6]", not "5 and 6 didn't come".
Quoted 4 lines
and 5 seems to have been eaten by a grue somewhere. It was a *big* patch mainly because all the caching flips over in a single go. If you want I can privately bounce 5 & 6 to you so you have a complete tree right now?
Thanks, but not interested, in the sense that it wouldn't make much sense to me to have a version tonight that is known to go stale within a few days. I only pick up and queue patches to 'pu' to save me from later trouble of finding them from the mailing list backlog, and not to actively review and engage in the discussion to polish them right now. We are already deep in pre-release freeze and my attention is not currently on anything that won't go in to the upcoming release.
I want to have a solid 1.6.6 before the holidays as a present to all ;-).
Re: [PATCH 1/6] GITWEB - Load Checking
In reply to Jakub NarebskiQuoted 9 lines · Jakub Narebski
gitweb/gitweb.perl if (-e $GITWEB_CONFIG) { · line 564
Quoted 6 lines
gitweb/gitweb.perl +6
-0+# loadavg throttle +sub get_loadavg() { + my $load; + my @loads; + + open($load, '<', '/proc/loadavg') or return 0;Why not use one of existing CPAN modules:
Sys::Info::Device::CPU,BSD::getloadavg,Sys::CpuLoad?
I would prefer to hear something along the lines of...
I like this. Here is a follow-up patch you can squash in to support other platforms.
I gave the patches a cursory look (I somehow didn't see 5/6, though) and they all looked decently done, except that some of the lines were excessively long.
Heya,
Quoted 7 lines · On Fri, Dec 11, 2009 at 00:45, John 'Warthog9' Hawley <[email protected]>…
John 'Warthog9' Hawley (6):
GITWEB - Load Checking
GITWEB - Missmatching git w/ gitweb
GITWEB - Addgit://link to summary pages
GITWEB -Makefilechanges
GITWEB - File based caching layer
GITWEB - Separate defaults from main file
I'd prefer not to be shouted at, how about s/GITWEB/gitweb: /g ? :)
Signature · 3 lines
Cheers, Sverre Rabbelier
Quoted 17 lines · "John 'Warthog9' Hawley" <[email protected]> writes:
Evening everyone,
This is the latest incarnation of gitweb w/ caching. This is finally at the point where it should probably start either being considered for inclusion or mainline, or I need to accept that this will never get in and more perminantely fork (as is the case with Fedora where this is going in as gitweb-caching as a parrallel rpm package).
That said this brings the base up to mainline (again), it updates a number of elements in the caching engine, and this is a much cleaner break-out of the tree vs. what I am currently developing against.
New things known to work:
- Better breakout
- You can actually disable the cache now
Quoted 8 lines
- John 'Warthog9' Hawley
John 'Warthog9' Hawley (6):
GITWEB - Load Checking
GITWEB - Missmatching git w/ gitweb
GITWEB - Addgit://link to summary pages
GITWEB -Makefilechanges
GITWEB - File based caching layer
This patch didn't made it to git mailing list. I suspect that you ran afoul vger anti-SPAM filter.
Does this "File based caching layer" have anything common with GSoC 2008 project, available at git://repo.or.cz/git/gitweb-caching.git ?
Quoted 1 line
GITWEB - Separate defaults from main file
Signature · 3 lines
Jakub Narebski Poland ShadeHawk on #git
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 20 lines · On Fri, 11 Dec 2009, J.H. (John 'Warthog9' Hawley) wrote:
Quoted 9 lines · Jakub Narebski
Quoted 6 lines · "John 'Warthog9' Hawley" <[email protected]> writes:
John 'Warthog9' Hawley (6):
GITWEB - Load Checking
GITWEB - Missmatching git w/ gitweb
GITWEB - Addgit://link to summary pages
GITWEB -Makefilechanges
GITWEB - File based caching layerQuoted 5 lines
This patch didn't made it to git mailing list. I suspect that you ran afoul vger anti-SPAM filter.
Does this "File based caching layer" have anything common with GSoC 2008 project, available at
git://repo.or.cz/git/gitweb-caching.git?Yeah, it does seem that way (like I said eaten by a grue), it *currently* has nothing to do with Lea's GSoC code but it is still my intention, long term, to integrate the two.
Quoted 7 lines
The patch, in all it's glory can be viewed at:
http://git.kernel.org/?p=git/warthog9/gitweb.git;a=commitdiff;h=42641b1e3bfae14d5cc2e0150355e89cb87951dbIt is anything but a small patch to gitweb, the patch is 117K and comprises 3539 lines (including git header commit information). There's not any real good way to break it up as it's a bit of an all or nothing patch.
First, why do you reinvent the wheel instead of using one of existing caching interfaces like CHI or Cache::Cache (perhaps creating a custom backend or middle layer which incorporates required features, like being load-aware)? This way changing from file-based cache to e.g. mmap based one or to memcached would be very simple. And you would avoid pitfals in doing your own cache management. perl-Cache-Cache should be available package in extras repositories.
If module is no available this would simply mean no caching, like in many (or not so many) other cases with optional features in gitweb.
Second, if you can't use CGI::Cache directly, you can always steal the idea from it, then the change to gitweb itself would be minimal:
"Internally, the CGI::Cache module ties the output file descriptor (usually STDOUT) to an internal variable to which all output is saved."
P.S. I'll postpone critique of the patch itself for now. The above issues are much more important.
Signature · 2 lines
Jakub Narebski Poland
Quoted 17 lines · Jakub Narebski
Quoted 16 lines · On Fri, 11 Dec 2009, J.H. (John 'Warthog9' Hawley) wrote:
Quoted 8 lines · Jakub Narebski
Quoted 6 lines · "John 'Warthog9' Hawley" <[email protected]> writes:
John 'Warthog9' Hawley (6):
GITWEB - Load Checking
GITWEB - Missmatching git w/ gitweb
GITWEB - Addgit://link to summary pages
GITWEB -Makefilechanges
GITWEB - File based caching layerQuoted 5 lines
This patch didn't made it to git mailing list. I suspect that you ran afoul vger anti-SPAM filter.
Does this "File based caching layer" have anything common with GSoC 2008 project, available at
git://repo.or.cz/git/gitweb-caching.git?Yeah, it does seem that way (like I said eaten by a grue), it *currently* has nothing to do with Lea's GSoC code but it is still my intention, long term, to integrate the two.
Quoted 8 lines
Quoted 3 lines
The patch, in all it's glory can be viewed at: http://git.kernel.org/?p=git/warthog9/gitweb.git;a=commitdiff;h=42641b1e3bfae14d5cc2e0150355e89cb87951db
It is anything but a small patch to gitweb, the patch is 117K and comprises 3539 lines (including git header commit information). There's not any real good way to break it up as it's a bit of an all or nothing patch.
First, why do you reinvent the wheel instead of using one of existing caching interfaces like CHI or
Cache::Cache(perhaps creating a custom backend or middle layer which incorporates required features, like being load-aware)?
Well for starters this isn't exactly a reinvention of the wheel, and this isn't something "new" per-se. This code has been actively running on git.kernel.org for something like 3 - 4 years so there's something to be said for the devil we know and understand. As well using the other caching strategies involves adding dramatically more complex interactions with caching layer. The caching layer is actually quite specific to how git + gitweb works and solves more than just "caching" on the surface. Specifically it solves the stampeding herd problem which would have to be solved either way even if I didn't implement my own caching, and since I had to do that caching was barely a step beyond that to implement.
Quoted 2 lines
This way changing from file-based cache to e.g. mmap based
one or to memcached would be very simple.
True but these are *VERY* different caching strategies than the one I've got here, yes it's using files as a backend but it's doing so with specific goals in mind. As I've said I plan to integrate Lea's memcached based caching into this in the future and that has different advantages and disadvantages.
At the end of the day the "normal" caching engines aren't as efficient as mine and there is the case the very high performance sites are going to have to investigate a number of different solutions to see what works best for them. Mine is also *dramatically* simpler to setup as well, turn it on, point it at a directory and your done.
Quoted 3 lines
And you would avoid pitfals
in doing your own cache management. perl-Cache-Cache should be available package in extras repositories.
There's pitfalls if I do it myself, or I use one of the other "common" perl modules. I did it this way years ago, I've maintained it and it works pretty well. I won't admit that it's the smartest caching engine on the planet, far from it, but it has evolved specifically for gitweb and that itself saves me a lot of pitfalls from cache engine + gitweb integration.
Quoted 2 lines
If module is no available this would simply mean no caching, like in many (or not so many) other cases with optional features in gitweb.
Yes, but as can be seen from how you enable various other caching engines the setup of those is non-trivial, this is and either way caching *HAS* to be explicitly turned on by the admin/user since they are going to have to do *some* configuration, or at least be aware that their webapp is going to chew up some sort of resource.
Quoted 5 lines
Second, if you can't use
CGI::Cachedirectly, you can always steal the idea from it, then the change to gitweb itself would be minimal:"Internally, the
CGI::Cachemodule ties the output file descriptor (usually STDOUT) to an internal variable to which all output is saved."
I thought about that 3 years ago, and decided it wasn't a good option for gitweb. Why? There's too many assumptions throughout the code that when you do a print it will go immediately out. Things like error messages and such. Breaking out the prints into prints (which will do what is expected) and passing around the output in the $output variables makes it a lot simpler easier to differentiate about how / what your looking at and a *LOT* easier to debug.
Quoted 2 lines
P.S. I'll postpone critique of the patch itself for now. The above issues are much more important.
That's fine. The issues your raising aren't new though, and stem back to before I created gitweb-caching, got rehashed with Lea's patches and not surprisingly are back on the table now. Like I said above, there is no one caching strategy that's perfect in all cases here and that's again why I eventually plan to merge Lea's changes (which uses memcached) in as well, I'm just trying to get code that I'm getting considerable demand for, that's proven, upstream.
- John 'Warthog9' Hawley
Quoted 11 lines · J.H.
Quoted 10 lines · Jakub Narebski
Quoted 9 lines · On Fri, 11 Dec 2009, J.H. (John 'Warthog9' Hawley) wrote:
Quoted 6 lines · Jakub Narebski
Quoted 3 lines · "John 'Warthog9' Hawley" <[email protected]> writes:
GITWEB - File based caching layer
This patch didn't made it to git mailing list. I suspect that you ran afoul vger anti-SPAM filter.
Yeah, it does seem that way (like I said eaten by a grue),
It _might_ be caused by the fact that you used attachement. But it might not; you can always use vger-taboo.perl script to check.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Does this "File based caching layer" have anything common with GSoC 2008 project, available at
git://repo.or.cz/git/gitweb-caching.git?It *currently* has nothing to do with Lea's GSoC code but it is still my intention, in long term, to integrate the two.
The question would be then whether it makes sense to have two caches at different levels in the stack (see also discussion below about Lea approach).
Quoted 13 lines
Quoted 8 lines
Quoted 7 lines
The patch, in all it's glory can be viewed at:
http://git.kernel.org/?p=git/warthog9/gitweb.git;a=commitdiff;h=42641b1e3bfae14d5cc2e0150355e89cb87951dbIt is anything but a small patch to gitweb, the patch is 117K and comprises 3539 lines (including git header commit information). There's not any real good way to break it up as it's a bit of an all or nothing patch.
Quoted 4 lines
First, why do you reinvent the wheel instead of using one of existing caching interfaces like CHI or
Cache::Cache(perhaps creating a custom backend or middle layer which incorporates required features, like being load-aware)?
Quoted 4 lines
Well for starters this isn't exactly a reinvention of the wheel, and this isn't something "new" per-se. This code has been actively running on git.kernel.org for something like 3 - 4 years so there's something to be said for the devil we know and understand.
Well, if it is not reinventing the wheel, then it is yak shaving (yet another ...) ;-)
The fact that the code was used and tested at one single installation doesn't mean that it doesn't have warts that could be avoided by using ready solution (at least for parts of it).
Quoted 3 lines
As well using the other
caching strategies involves adding dramatically more complex interactions with caching layer.
I am hoping that if it was done right, by using CHI or Cache::Cache caching interface, then choosing alternate caching engine, or adding extra level of cache would be simple and decoupled from issues specific to web app or gitweb in particular.
Quoted 3 lines
The caching layer is actually quite
specific to how git + gitweb works and solves more than just "caching" on the surface.
The idea is for gitweb/cache.pm (or gitweb/Gitweb-Cache.pm, or gitweb/Gitweb/Cache.pm) is to encapsulate issues specific to gitweb, like generating cache key, or printing "Generating...", etc.
Perhaps also the idea of filling cache in background (but see discussion below about capturing STDOUT) could be put there.
Quoted 4 lines
Specifically it solves the stampeding herd problem
which would have to be solved either way even if I didn't implement my own caching, and since I had to do that caching was barely a step beyond that to implement.
CHI tries to solve cache miss stampedes via expires_variance mechanism. There is Cache::Adaptive (and its subclass Cache::Adaptive::ByLoad) which does adaptive lifetime control (it accepts any Cache::Cache compatible cache, so I think it also accepts CHI compatible cache). Those problems _were_ solved.
Quoted 8 lines
Quoted 2 lines
This way changing from file-based cache to e.g. mmap based
one or to memcached would be very simple.True but these are *VERY* different caching strategies than the one I've got here, yes it's using files as a backend but it's doing so with specific goals in mind. As I've said I plan to integrate Lea's memcached based caching into this in the future and that has different advantages and disadvantages.
Errr... besides using Cache::Cache compatible cache (see!!!), for example Cache::Memcached, Lea Wiemann's gitweb caching did caching at entirely different level than original kernel.org's gitweb.
The stack for gitweb looks somewhat like this:
git commands output open my $fd, '-|, git_cmd(), ...
|
v
parsed output data parse_ls_tree_line, parse_commit, ...
|
v generated HTML etc. print ...
:
V
caching optional
reverse proxy Varnish, Squid
If I understand correctly Lea Wiemann code cache git command output. The fork of gitweb used at repo.or.cz does caching of parsed data at least for most intensive projects list page. This patch was about caching generated output. HTTP caching requires that gitweb can respond to If-Modified-Since (and generate Last-Modified) and If-None-Match (and generate ETag) in a time that is much faster than generating full response.
There are advantages and disadvantages for each method of caching; also the balance might depend on the view used. For example 'snapshot' view is best cached via output caching with file-based cache, while for 'blame_incremental' view straight caching of output doesn't make much sense while caching command output should give good behaviour.
Quoted 5 lines
At the end of the day the "normal" caching engines aren't as efficient as mine and there is the case the very high performance sites are going to have to investigate a number of different solutions to see what works best for them. Mine is also *dramatically* simpler to setup as well, turn it on, point it at a directory and you're done.
Do you have any benchmarks?
Quoted 10 lines
Quoted 3 lines
And you would avoid pitfals
in doing your own cache management. perl-Cache-Cache should be available package in extras repositories.There's pitfalls if I do it myself, or I use one of the other "common" perl modules. I did it this way years ago, I've maintained it and it works pretty well. I won't admit that it's the smartest caching engine on the planet, far from it, but it has evolved specifically for gitweb and that itself saves me a lot of pitfalls from cache engine + gitweb integration.
If I remember correctly the solution presented here has serious disadvantage of not having any cache expire policy, and not being size-aware.
Quoted 8 lines
Quoted 2 lines
If module is no available this would simply mean no caching, like in many (or not so many) other cases with optional features in gitweb.
Yes, but as can be seen from how you enable various other caching engines the setup of those is non-trivial, this is and either way caching *HAS* to be explicitly turned on by the admin/user since they are going to have to do *some* configuration, or at least be aware that their webapp is going to chew up some sort of resource.
I wonder if there is any data that describes when one should enable caching, and when one can do without it, e.g. depending on the number and total size of repositories presented via gitweb.
IMHO cache storage is orthogonal to expire policy, which in turn is orthogonal on cache use in gitweb. And those parts should be kept separate (and tested independently), even if we decide on homegrown caching solution.
Quoted 6 lines
Quoted 5 lines
Second, if you can't use
CGI::Cachedirectly, you can always steal the idea from it, then the change to gitweb itself would be minimal:"Internally, the
CGI::Cachemodule ties the output file descriptor (usually STDOUT) to an internal variable to which all output is saved."
Quoted 7 lines
I thought about that 3 years ago, and decided it wasn't a good option for gitweb. Why? There's too many assumptions throughout the code that when you do a print it will go immediately out. Things like error messages and such. Breaking out the prints into prints (which will do what is expected) and passing around the output in the $output variables makes it a lot simpler easier to differentiate about how / what your looking at and a *LOT* easier to debug.
Note that in quite a few places we print directly to output, streaming the response, for performance (to reduce latency). If all data must be first gathered in $output variable (increasing memory pressure in the case of large files for 'blob_plain', large snapshots, large patches in 'patch' and 'patches' views) then we must wait for it to finish, and not get data as soon as it is available.
Besides instead of just capturing STDOUT in tied variable (STDERR goes to web server log courtesy of CGI.pm) we can tee it, i.e. capture it to $output variable as it is streamed to web browser. See Capture::Tiny (although I am not sure how it would interact with CGI.pm logging) and e.g. PerlIO::tee mechanism from PerlIO::Util.
Going the route of CGI::Cache would mean minimal changes to gitweb... and no diference in performance if caching is turned off (see streaming).
Quoted 10 lines
Quoted 2 lines
P.S. I'll postpone critique of the patch itself for now. The above issues are much more important.That's fine. The issues your raising aren't new though, and stem back to before I created gitweb-caching, got rehashed with Lea's patches and not surprisingly are back on the table now. Like I said above, there is no one caching strategy that's perfect in all cases here and that's again why I eventually plan to merge Lea's changes (which uses memcached) in as well, I'm just trying to get code that I'm getting considerable demand for, that's proven, upstream.
Well, there are two solutions. One is first to decide on proper solution for gitweb caching. Another is to have _some_ caching and then improve it.
So below there are a few initial comments about gitweb/cache.pm code:
* gitweb/cache.pm should be, I think, a proper module (require'd or use'd)
* you do not follow coding style used elsewhere in gitweb, e.g. spaces around {} and (), for example it is
}elsif( $cache_enable == 1 ){and should be
} elsif ($cache_enable == 1) {* flags that are boolean are compared to 0 and 1
* cache key should be generated from both PATH_INFO and QUERY_STRING in generic case (unless you turn off $path_info as default, and turn off support for path_info URLs); see %input_params hash or href(-replay=>1)
* gitweb till now does not include any variable data in error info
* duplicated code (e.g. fork / cacheUpdate + cacheDisplay / cacheUpdate...)
* inconsistent naming style: cache_fetch but cacheDisplay.
* old style open using globs instead of local filehandles:
open(cacheFile, '<', "$fullhashpath");
and should be
open(my $cache_fh, '<', $fullhashpath);
* busy wait 'do { sleep 2; open ... } while (...)' instead of non-blocking wait like select / IO::Select.
That's all from skimming gitweb-ml-v2:gitweb/cache.pm
Signature · 2 lines
Jakub Narebski Poland