]> git.ipfire.org Git - thirdparty/git.git/commit - upload-pack.c
upload-pack: look up "want" lines via commit-graph
authorPatrick Steinhardt <ps@pks.im>
Tue, 1 Mar 2022 09:33:37 +0000 (10:33 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 1 Mar 2022 18:13:45 +0000 (10:13 -0800)
commit4de656263aa195080495fc0a103351b9eaac8160
treef7b97b2415f0bf9b3b2e50c729bab2a9006badfd
parent34363403a28ad4d0bd76c5aa7351293b6e4a4e47
upload-pack: look up "want" lines via commit-graph

During packfile negotiation the client will send "want" and "want-ref"
lines to the server to tell it which objects it is interested in. The
server-side parses each of those and looks them up to see whether it
actually has requested objects. This lookup is performed by calling
`parse_object()` directly, which thus hits the object database. In the
general case though most of the objects the client requests will be
commits. We can thus try to look up the object via the commit-graph
opportunistically, which is much faster than doing the same via the
object database.

Refactor parsing of both "want" and "want-ref" lines to do so.

The following benchmark is executed in a repository with a huge number
of references. It uses cached request from git-fetch(1) as input to
git-upload-pack(1) that contains about 876,000 "want" lines:

    Benchmark 1: HEAD~
      Time (mean ± σ):      7.113 s ±  0.028 s    [User: 6.900 s, System: 0.662 s]
      Range (min … max):    7.072 s …  7.168 s    10 runs

    Benchmark 2: HEAD
      Time (mean ± σ):      6.622 s ±  0.061 s    [User: 6.452 s, System: 0.650 s]
      Range (min … max):    6.535 s …  6.727 s    10 runs

    Summary
      'HEAD' ran
        1.07 ± 0.01 times faster than 'HEAD~'

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
upload-pack.c