git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] fetch-pack: grow stateless RPC windows exponentially

From
Stefan Beller <sbeller@google.com>
Date
Jul 19, 2016, 16:46 UTC
Message-ID
<CAGZ79kY+2PYx9oz9tvi0zG-oE6qS-Za7D3ocY1XtqcSsDchz0Q@mail.gmail.com>
In-Reply-To
<1468880498-30235-1-git-send-email-jonathantanmy@google.com>
On Mon, Jul 18, 2016 at 3:21 PM, Jonathan Tan <jonathantanmy@google.com> wrote:
Show 5 quoted lines
> When updating large repositories, the LARGE_FLUSH limit (that is, the
> limit at which the window growth strategy switches from exponential to
> linear) is reached quite quickly. Use a conservative exponential growth
> strategy when that limit is reached instead (and increase LARGE_FLUSH so
> that there is no regression in window size).
Care to elaborate on why you choose 11/10 as growth factor?

(As someone who has a tick in micro optimizing: 9/8 is roughly the same exponent, but the division by 8 is easier as it is just a shift by 3. Similar 17/16)

I guess one design criterion was 10 being a round number? Does it make sense to experiment with the factor at all? Digging into that, LARGE_FLUSH originates from 6afca450c3f, (2011-03-20, fetch-pack: progressively use larger handshake windows), and before we only had a linear growth.

So I guess what I do not understand is why we need to slow down the exponential growth at all?

Thanks, Stefan

Show 46 quoted lines
>
> This optimization is only applied during stateless RPCs to avoid the
> issue raised and fixed in commit
> 44d8dc54e73e8010c4bdf57a422fc8d5ce709029.
>
> Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
> ---
>  fetch-pack.c | 19 ++++++++++++-------
>  1 file changed, 12 insertions(+), 7 deletions(-)
>
> diff --git a/fetch-pack.c b/fetch-pack.c
> index b501d5c..85e77af 100644
> --- a/fetch-pack.c
> +++ b/fetch-pack.c
> @@ -243,16 +243,21 @@ static void insert_one_alternate_ref(const struct ref *ref, void *unused)
>
>  #define INITIAL_FLUSH 16
>  #define PIPESAFE_FLUSH 32
> -#define LARGE_FLUSH 1024
> +#define LARGE_FLUSH 16384
>
>  static int next_flush(struct fetch_pack_args *args, int count)
>  {
> -       int flush_limit = args->stateless_rpc ? LARGE_FLUSH : PIPESAFE_FLUSH;
> -
> -       if (count < flush_limit)
> -               count <<= 1;
> -       else
> -               count += flush_limit;
> +       if (args->stateless_rpc) {
> +               if (count < LARGE_FLUSH)
> +                       count <<= 1;
> +               else
> +                       count = count * 11 / 10;
> +       } else {
> +               if (count < PIPESAFE_FLUSH)
> +                       count <<= 1;
> +               else
> +                       count += PIPESAFE_FLUSH;
> +       }
>         return count;
>  }
>
> --
> 2.8.0.rc3.226.g39d4020
>
Previous: Jonathan NiederNext: Jonathan Tan
Message 11 of 17 in “fetch-pack: grow stateless RPC windows exponentially”
  1. fetch-pack: grow stateless RPC windows exponentiallyJonathan Tan, Jul 18, 2016
  2. Jonathan NiederJul 18, 2016
  3. Junio C HamanoJul 18, 2016
  4. Jonathan TanJul 18, 2016
  5. Jonathan NiederJul 18, 2016
  6. Junio C HamanoJul 18, 2016
  7. Jonathan TanJul 18, 2016
  8. Junio C HamanoJul 18, 2016
  9. fetch-pack: grow stateless RPC windows exponentiallyJonathan Tan, Jul 18, 2016
  10. Jonathan NiederJul 18, 2016
  11. Stefan BellerJul 19, 2016
  12. Jonathan TanJul 19, 2016
  13. Stefan BellerJul 19, 2016
  14. Junio C HamanoJul 19, 2016
  15. Jonathan NiederJul 19, 2016
  16. Junio C HamanoJul 19, 2016
  17. Jeff KingJul 20, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.