Skip to content

Commit

Permalink
send-pack.c: add config push.useBitmaps
Browse files Browse the repository at this point in the history
This allows you to disable bitmaps for "git push". Default is false.

Reachability bitmaps are designed to speed up the "counting objects"
phase of generating a pack during a clone or fetch. They are not
optimized for Git clients sending a small topic branch via "git push".
In some cases (see [1]), using reachability bitmaps during "git push"
can cause significant performance regressions.

Add a new "push.useBitmaps" config option to disable reachability
bitmaps during "git push". This allows reachability bitmaps to still
be used in other areas, such as "git rev-list --use-bitmap-index".

[1]: https://lore.kernel.org/git/87zhoz8b9o.fsf@evledraar.gmail.com/

Signed-off-by: Kyle Zhao <kylezhao@tencent.com>
  • Loading branch information
keyu98 committed Jun 16, 2022
1 parent 8168d5e commit 91ce038
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Documentation/config/push.txt
Expand Up @@ -137,3 +137,8 @@ push.negotiate::
server attempt to find commits in common. If "false", Git will
rely solely on the server's ref advertisement to find commits
in common.

push.useBitmaps::
If this config and `pack.useBitmaps` are both `true`, then Git will
use reachability bitmaps during `git push`, if available (disabled
by default).
5 changes: 5 additions & 0 deletions send-pack.c
Expand Up @@ -84,6 +84,8 @@ static int pack_objects(int fd, struct ref *refs, struct oid_array *advertised,
strvec_push(&po.args, "--progress");
if (is_repository_shallow(the_repository))
strvec_push(&po.args, "--shallow");
if (!args->use_bitmaps)
strvec_push(&po.args, "--no-use-bitmap-index");
po.in = -1;
po.out = args->stateless_rpc ? -1 : fd;
po.git_cmd = 1;
Expand Down Expand Up @@ -482,6 +484,7 @@ int send_pack(struct send_pack_args *args,
int use_push_options = 0;
int push_options_supported = 0;
int object_format_supported = 0;
int use_bitmaps = 0;
unsigned cmds_sent = 0;
int ret;
struct async demux;
Expand All @@ -497,6 +500,8 @@ int send_pack(struct send_pack_args *args,
git_config_get_bool("push.negotiate", &push_negotiate);
if (push_negotiate)
get_commons_through_negotiation(args->url, remote_refs, &commons);
if (!git_config_get_bool("push.usebitmaps", &use_bitmaps))
args->use_bitmaps = use_bitmaps;

git_config_get_bool("transfer.advertisesid", &advertise_sid);

Expand Down
3 changes: 2 additions & 1 deletion send-pack.h
Expand Up @@ -26,7 +26,8 @@ struct send_pack_args {
/* One of the SEND_PACK_PUSH_CERT_* constants. */
push_cert:2,
stateless_rpc:1,
atomic:1;
atomic:1,
use_bitmaps:1;
const struct string_list *push_options;
};

Expand Down
21 changes: 21 additions & 0 deletions t/t5516-fetch-push.sh
Expand Up @@ -1865,4 +1865,25 @@ test_expect_success 'push warns or fails when using username:password' '
test_line_count = 1 warnings
'

test_expect_success 'push with config push.useBitmaps' '
mk_test testrepo heads/main &&
git checkout main &&
GIT_TRACE2_EVENT="$PWD/default" \
git push testrepo main:test &&
test_subcommand git pack-objects --all-progress-implied --revs --stdout \
--thin --delta-base-offset -q --no-use-bitmap-index <default &&
git config push.useBitmaps true &&
GIT_TRACE2_EVENT="$PWD/true" \
git push testrepo main:test2 &&
test_subcommand git pack-objects --all-progress-implied --revs --stdout \
--thin --delta-base-offset -q <true &&
git config push.useBitmaps false &&
GIT_TRACE2_EVENT="$PWD/false" \
git push testrepo main:test3 &&
test_subcommand git pack-objects --all-progress-implied --revs --stdout \
--thin --delta-base-offset -q --no-use-bitmap-index <false
'

test_done

0 comments on commit 91ce038

Please sign in to comment.