1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-11-05 08:47:56 +01:00
git/contrib/persistent-https
Colby Ranger fe0435011c Add persistent-https to contrib
Git over HTTPS has a high request startup latency, since the SSL
negotiation can take up to a second. In order to reduce this latency,
connections should be left open to the Git server across requests
(or invocations of the git commandline).

Reduce SSL startup latency by running a daemon job that keeps
connections open to a Git server. The daemon job
(git-remote-persistent-https--proxy) is started on the first request
through the client binary (git-remote-persistent-https) and remains
running for 24 hours after the last request, or until a new daemon
binary is placed in the PATH. The client determines the daemon's
HTTP address by communicating over a UNIX socket with the daemon.
From there, the rest of the Git protocol work is delegated to the
"git-remote-http" binary, with the environment's http_proxy set to
the daemon.

Accessing /pub/scm/linux/kernel/git/torvalds/linux repository hosted
at kernel.googlesource.com with "git ls-remote" over https:// and
persistent-https:// 5 times shows that the first request takes about
the same time (0.193s vs 0.208s---there is a slight set-up cost for
the local proxy); as expected, the other four requests are much
faster (~0.18s vs ~0.08s).

Incidentally, this also has the benefit of HTTP keep-alive working
across Git command invocations. Its common for servers to use a 5
minute keep-alive on an HTTP 1.1 connection. Git-over-HTTP commonly
uses Transfer-Encoding: chunked on replies, so keep-alive will
generally just work, even though a pack stream's length isn't known
in advance. Because the helper is an external process holding that
connection open, we also benefit from being able to reuse an
existing TCP connection to the server.  The same "git ls-remote"
test against http:// vs persistent-https:// URL shows that the
former takes ~0.09s while the first request for the latter is about
0.134s with set-up cost, and subsequent requests are ~0.065s,
shaving around one RTT to the server.

Signed-off-by: Colby Ranger <cranger@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-30 13:50:45 -07:00
..
client.go Add persistent-https to contrib 2012-05-30 13:50:45 -07:00
LICENSE Add persistent-https to contrib 2012-05-30 13:50:45 -07:00
main.go Add persistent-https to contrib 2012-05-30 13:50:45 -07:00
Makefile Add persistent-https to contrib 2012-05-30 13:50:45 -07:00
proxy.go Add persistent-https to contrib 2012-05-30 13:50:45 -07:00
README Add persistent-https to contrib 2012-05-30 13:50:45 -07:00
socket.go Add persistent-https to contrib 2012-05-30 13:50:45 -07:00

git-remote-persistent-https

The git-remote-persistent-https binary speeds up SSL operations
by running a daemon job (git-remote-persistent-https--proxy) that
keeps a connection open to a server.


PRE-BUILT BINARIES

Darwin amd64:
https://commondatastorage.googleapis.com/git-remote-persistent-https/darwin_amd64.tar.gz

Linux amd64:
https://commondatastorage.googleapis.com/git-remote-persistent-https/linux_amd64.tar.gz


INSTALLING

Move all of the git-remote-persistent-http* binaries to a directory
in PATH.


USAGE

HTTPS requests can be delegated to the proxy by using the
"persistent-https" scheme, e.g.

git clone persistent-https://kernel.googlesource.com/pub/scm/git/git

Likewise, .gitconfig can be updated as follows to rewrite https urls
to use persistent-https:

[url "persistent-https"]
	insteadof = https
[url "persistent-http"]
	insteadof = http


#####################################################################
# BUILDING FROM SOURCE
#####################################################################

LOCATION

The source is available in the contrib/persistent-https directory of
the Git source repository. The Git source repository is available at
git://git.kernel.org/pub/scm/git/git.git/
https://kernel.googlesource.com/pub/scm/git/git


PREREQUISITES

The code is written in Go (http://golang.org/) and the Go compiler is
required. Currently, the compiler must be built and installed from tip
of source, in order to include a fix in the reverse http proxy:
http://code.google.com/p/go/source/detail?r=a615b796570a2cd8591884767a7d67ede74f6648


BUILDING

Run "make" to build the binaries. See the section on
INSTALLING above.