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

Re: [PATCH 1/1] upload-pack.c: make output buffer size configurable

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Dec 14, 2021, 12:08 UTC
Message-ID
<211214.86y24nbd46.gmgdl@evledraar.gmail.com>
In-Reply-To
<20211213132345.26310-2-jacob@gitlab.com>
On Mon, Dec 13 2021, Jacob Vosmaer wrote:
Show 44 quoted lines
> Add a new compile time constant UPLOAD_PACK_BUFFER_SIZE that makes the
> size of the static buffer in output_state configurable.
>
> The current size of the buffer is 8192+1. The '+1' is a technical
> detail orthogonal to this change. On GitLab.com we use GitLab's
> pack-objects cache which does writes of 65515 bytes. Because of the
> default 8KB buffer size, propagating these cache writes requires 8
> pipe reads and 8 pipe writes from git-upload-pack, and 8 pipe reads
> from Gitaly (our Git RPC service). If we increase the size of the
> buffer to the maximum Git packet size, we need only 1 pipe read and 1
> pipe write in git-upload-pack, and 1 pipe read in Gitaly to transfer
> the same amount of data. In benchmarks with a pure fetch and 100%
> cache hit rate workload we are seeing CPU utilization reductions of
> over 30%.
>
> Signed-off-by: Jacob Vosmaer <jacob@gitlab.com>
> ---
>  upload-pack.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/upload-pack.c b/upload-pack.c
> index c78d55bc67..b799fbe628 100644
> --- a/upload-pack.c
> +++ b/upload-pack.c
> @@ -42,6 +42,10 @@
>  #define ALL_FLAGS (THEY_HAVE | OUR_REF | WANTED | COMMON_KNOWN | SHALLOW | \
>  		NOT_SHALLOW | CLIENT_SHALLOW | HIDDEN_REF)
>  
> +#ifndef UPLOAD_PACK_BUFFER_SIZE
> +#define UPLOAD_PACK_BUFFER_SIZE 8192
> +#endif
> +
>  /* Enum for allowed unadvertised object request (UOR) */
>  enum allow_uor {
>  	/* Allow specifying sha1 if it is a ref tip. */
> @@ -194,7 +198,7 @@ static int write_one_shallow(const struct commit_graft *graft, void *cb_data)
>  }
>  
>  struct output_state {
> -	char buffer[8193];
> +	char buffer[UPLOAD_PACK_BUFFER_SIZE+1];
>  	int used;
>  	unsigned packfile_uris_started : 1;
>  	unsigned packfile_started : 1;

Making this configurable obviousl has big impact in some cases, but I'm a bit iffy on the faciltity to do so + it not being documented.

I don't think that the "static buffer" part here is important to anyone, but the write() size is clearly important.

So doesn't it make more sense to have a uploadPack.bufferSize=8k variable we can tweak, just make this "buffer" a "struct strbuf" instead (i.e. it'll by dynamically grown), and then just flush it whenever we hit the configured buffer size?

Previous: Jacob VosmaerNext: Jeff King
Message 3 of 17 in “Make upload-pack pack write size configurable”
  1. 0/1 Make upload-pack pack write size configurableJacob Vosmaer, Dec 13, 2021
  2. 1/1 upload-pack.c: make output buffer size configurableJacob Vosmaer, Dec 13, 2021
  3. Ævar Arnfjörð BjarmasonDec 14, 2021
  4. Jeff KingDec 14, 2021
  5. 0/1 upload-pack.c: increase output buffer sizeJacob Vosmaer, Dec 14, 2021
  6. 1/1 upload-pack.c: increase output buffer sizeJacob Vosmaer, Dec 14, 2021
  7. Ævar Arnfjörð BjarmasonDec 14, 2021
  8. Jeff KingDec 15, 2021
  9. Junio C HamanoDec 15, 2021
  10. rsbecker@nexbridge.comDec 15, 2021
  11. Jacob VosmaerDec 15, 2021
  12. rsbecker@nexbridge.comDec 15, 2021
  13. Jacob VosmaerDec 15, 2021
  14. rsbecker@nexbridge.comDec 15, 2021
  15. Jeff KingDec 14, 2021
  16. Jacob VosmaerDec 14, 2021
  17. Jeff KingDec 14, 2021

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.