Windows Apache 2.2 painfully slow executing CGI

apache-2.2cgigitperlwindows

I've recently set up Apache 2.2 and git on one of our Windows XP PCs for gitweb access using the setup at https://git.wiki.kernel.org/index.php/MSysGit:GitWeb
As noted on the wiki, the only version of Perl that seems to work with gitweb the way it is coded is the one included with MSysGit. ActivePerl and StrawberryPerl don't implement a certain required feature so another interpreter is not an option.

C:\Program Files\Git\bin>perl.exe --version
This is perl, v5.8.8 built for msys

In any case, it is set up and it works but for some reason there is an approximately 10 second delay for every page load. To troubleshoot this I made a simple helloworld.cgi and placed it in the directory next to gitweb.cgi. It is set up to use the same perl interpreter as gitweb:

#!C:\Program Files\Git\bin\perl.exe
print "Content-type: text/html\n\n";
print "Hello, world!\n";

This script too takes over 10 seconds to execute on the server. If I fire up a command prompt and execute it directly with the same perl executable, it executes instantly.

mod_cgi is loaded in the Apache config and I'm using the config stanzas shown on the git wiki modified for my system:

# Config to make the gitweb CGI available through Apache.
Alias /git "C:/Program Files/Git/share/gitweb"
<Directory "C:/Program Files/Git/share/gitweb">
  AddHandler cgi-script .cgi
  <Files ~ "\.cgi$">
    Options +ExecCGI
  </Files>
  AllowOverride None
  Order allow,deny
  Allow from all
  DirectoryIndex gitweb.cgi
</Directory>

Are there some other config directives I'm missing? It doesn't seem to matter whether I access it from another PC or via localhost directly on the machine so I think that rules out DNS. It isn't dumping anything into the Apache error log, either.

Best Answer

I fixed this by using cygwin's version of Perl instead of msysgit. That will really speed up your response time.

To do this, you will need to modify the gitweb.cgi script in 3 places The first line should say this:

#!C:/cygwin/bin/perl

I choose to use cygwin's version of git instead of msysgit's as well, so you need to make sure the projectroot is in cygwin's format:

our $GIT = "C:/cygwin/bin/git";
our $projectroot = "/cygdrive/c/temp/repos";
Related Topic