Subject: [bug#44567] [PATCH] publish: Improve HTTP performance when not using --cache.

From: Ludovic Courtès <[email-masked]>
Date: Fri, 13 Nov 2020 18:19:03 +0100

Hi Maxim,

Maxim Cournoyer <[email-masked]> skribis:

> This change harmonizes the way we configure the buffer sizes and the socket
> options, so that we don't forget to change it at one place like it happened in
> commit 5e3d169945935b53325e6b738a307ba286751259.  Using a greater socket
> buffer size reportedly improves throughput tenfold.
>
> The solution was found by Ludovic Courtès.
>
> * guix/scripts/publish.scm (%default-buffer-size)
> (%default-socket-options): New variables.
> * guix/scripts/publish.scm (configure-socket): New procedure.
> (compress-nar): Use %default-buffer-size for the buffer size, increased from
> 128 to 208 KiB.
> (nar-response-port): Likewise, increased from 64 to 208 KiB.
> (http-write): Use configure-socket to set socket options.
> (open-server-socket): Likewise.

Apologies for not noticing this before pushing
1cbda46d4aae5ba9bd89a1837f0d81a29653ed7b.  What you propose here is
nicer.

> +(define %default-buffer-size
> +  (* 208 1024))

Why 208?  Did you notice a difference compared to 128KiB?  (I’m fine
either way, just wondering.)

Perhaps add a comment as to what buffer we’re talking about.

> +(define %default-socket-options

Maybe add: ;; List of options passed to 'setsockopt' when transmitting files.

> +  (list (list SO_SNDBUF %default-buffer-size)))

>       (make-gzip-output-port (response-port response)
>                              #:level level
> -                            #:buffer-size (* 64 1024)))
> +                            #:buffer-size %default-buffer-size))

Does the gzip buffer size have to match the TCP buffer size?  I’d say
not necessarily, so perhaps we should have a separate variable for the
gzip buffer size (or keep it as is).

That’s it, thank you!

Ludo’.