git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Xiaowen Xia <haoyurenzhuxia@gmail.com>
To: Bagas Sanjaya <bagasdotme@gmail.com>
Cc: git@vger.kernel.org, gitster@pobox.com, peff@peff.net,
	worldhello.net@gmail.com,
	Xia XiaoWen <chenan.xxw@alibaba-inc.com>
Subject: Re: [PATCH] add http.maxReceiveSpeed to limit git-receive-pack receiving speed
Date: Thu, 19 Aug 2021 19:27:41 +0800	[thread overview]
Message-ID: <CAHLXgnZQmLiLbGnbC-nouE6tTJam5ZmdRmj=8E+tmM1pNLVFXw@mail.gmail.com> (raw)
In-Reply-To: <a097e447-28e7-d991-ac99-ce1ffdb3ead4@gmail.com>

> I mean "In some situations it is preferable to limit receiving speed of
> git clone/fetch due to network bandwidth constraint, otherwise other
> applications performance will suffer from degraded network performance.".
Thanks!

> Wouldn't it make sense for negative speed? Why don't just return error
> if negative speed is set?
You are right, negative speed doesn't make sense. but I prefer printf
a warning and continue work instead of returning an error, negative
speed seems not a fatal error.

> Why is there boilerplate #if #endif block for libcurl 7.15.5?
The speed limit depends on the `CURLOPT_MAX_RECV_SPEED_LARGE` provided
by libCURL, and libCURL added `CURLOPT_MAX_RECV_SPEED_LARGE` in
7.15.5: https://curl.se/changes.html#7_15_5 .

Bagas Sanjaya <bagasdotme@gmail.com> 于2021年8月19日周四 下午5:36写道:
>
> On 19/08/21 16.14, Xia XiaoWen wrote:
> > Sometimes need to limit the receive speed of git `clone/fetch`
> > because of the limited network bandwidth, otherwise will prevent
> > other applications from using the network normally.
> >
> I mean "In some situations it is preferable to limit receiving speed of
> git clone/fetch due to network bandwidth constraint, otherwise other
> applications performance will suffer from degraded network performance.".
>
> > Add `http.maxReceiveSpeed` to limit `git-receive-pack` receiving
> > speed, Can be overridden by `GIT_HTTP_MAX_RECEIVE_SPEED` eivironment
> > variable.
> >
> s/eivironment/environment/
>
> > The default is unlimited, same if the value is 0 or negative. The
> > default unit is Bytes/s, common unit suffixes of k, m, or g are supported.
> >
>
> Wouldn't it make sense for negative speed? Why don't just return error
> if negative speed is set?
>
> > this configuration is valid for `clone`, `fetch`, `pull` commands of the
> > https protocol, and only supports libcurl 7.15.5 and above.
> > ---
> >   http.c | 24 +++++++++++++++++++++++-
> >   1 file changed, 23 insertions(+), 1 deletion(-)
> >
> > diff --git a/http.c b/http.c
> > index 8119247149..12030cf3bc 100644
> > --- a/http.c
> > +++ b/http.c
> > @@ -83,6 +83,9 @@ static const char *ssl_pinnedkey;
> >   static const char *ssl_cainfo;
> >   static long curl_low_speed_limit = -1;
> >   static long curl_low_speed_time = -1;
> > +#if LIBCURL_VERSION_NUM >= 0x070f05
> > +static ssize_t curl_max_receive_speed = -1;
> > +#endif
> >   static int curl_ftp_no_epsv;
> >   static const char *curl_http_proxy;
> >   static const char *http_proxy_authmethod;
> > @@ -361,7 +364,12 @@ static int http_options(const char *var, const char *value, void *cb)
> >               curl_low_speed_time = (long)git_config_int(var, value);
> >               return 0;
> >       }
> > -
> > +#if LIBCURL_VERSION_NUM >= 0x070f05
> > +     if (!strcmp("http.maxreceivespeed", var)) {
> > +             curl_max_receive_speed = git_config_ssize_t(var, value);
> > +             return 0;
> > +     }
> > +#endif
> >       if (!strcmp("http.noepsv", var)) {
> >               curl_ftp_no_epsv = git_config_bool(var, value);
> >               return 0;
> > @@ -974,6 +982,12 @@ static CURL *get_curl_handle(void)
> >                                curl_low_speed_time);
> >       }
> >
> > +#if LIBCURL_VERSION_NUM >= 0x070f05
> > +     if (curl_max_receive_speed > 0)
> > +             curl_easy_setopt(result, CURLOPT_MAX_RECV_SPEED_LARGE,
> > +                              curl_max_receive_speed);
> > +#endif
> > +
> >       curl_easy_setopt(result, CURLOPT_MAXREDIRS, 20);
> >   #if LIBCURL_VERSION_NUM >= 0x071301
> >       curl_easy_setopt(result, CURLOPT_POSTREDIR, CURL_REDIR_POST_ALL);
> > @@ -1105,6 +1119,9 @@ void http_init(struct remote *remote, const char *url, int proactive_auth)
> >   {
> >       char *low_speed_limit;
> >       char *low_speed_time;
> > +#if LIBCURL_VERSION_NUM >= 0x070f05
> > +     char *max_receive_speed;
> > +#endif
> >       char *normalized_url;
> >       struct urlmatch_config config = { STRING_LIST_INIT_DUP };
> >
> > @@ -1196,6 +1213,11 @@ void http_init(struct remote *remote, const char *url, int proactive_auth)
> >       low_speed_time = getenv("GIT_HTTP_LOW_SPEED_TIME");
> >       if (low_speed_time != NULL)
> >               curl_low_speed_time = strtol(low_speed_time, NULL, 10);
> > +#if LIBCURL_VERSION_NUM >= 0x070f05
> > +     max_receive_speed = getenv("GIT_HTTP_MAX_RECEIVE_SPEED");
> > +     if (max_receive_speed && !git_parse_ssize_t(max_receive_speed, &curl_max_receive_speed))
> > +             warning("failed to parse GIT_HTTP_MAX_RECEIVE_SPEED: %s", max_receive_speed);
> > +#endif
> >
> >       if (curl_ssl_verify == -1)
> >               curl_ssl_verify = 1;
> >
>
> Why is there boilerplate #if #endif block for libcurl 7.15.5?
>
> --
> An old man doll... just what I always wanted! - Clara

  reply	other threads:[~2021-08-19 11:27 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-19  9:14 [PATCH] add http.maxReceiveSpeed to limit git-receive-pack receiving speed Xia XiaoWen
2021-08-19  9:36 ` Bagas Sanjaya
2021-08-19 11:27   ` Xiaowen Xia [this message]
2021-08-19 18:28 ` Junio C Hamano
2021-08-20 18:11   ` Jeff King
2021-08-20 18:21     ` Randall S. Becker
2021-08-21  3:19   ` Xiaowen Xia
2021-08-21  4:21     ` Junio C Hamano
2021-08-21  5:16       ` Xiaowen Xia
2021-08-23 16:04 ` [PATCH v2] http: add http.maxReceiveSpeed to limit receiving speed of "git-receive-pack" chenan.xxw
2021-08-24  0:31   ` Jiang Xin
2021-08-31  4:15     ` Xiaowen Xia

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAHLXgnZQmLiLbGnbC-nouE6tTJam5ZmdRmj=8E+tmM1pNLVFXw@mail.gmail.com' \
    --to=haoyurenzhuxia@gmail.com \
    --cc=bagasdotme@gmail.com \
    --cc=chenan.xxw@alibaba-inc.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    --cc=worldhello.net@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).