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

Re: [PATCH] read-cache: increase write buffer size

From
Pranit Bauva <pranit.bauva@gmail.com>
Date
Mar 19, 2016, 10:25 UTC
Message-ID
<CAFZEwPMtv0JF+Q_1P53NB2oxH-XJXGzmiUsOxk0KBaa+AJE+vA@mail.gmail.com>
In-Reply-To
<56ED0863.3020709@web.de>
On Sat, Mar 19, 2016 at 1:35 PM, Torsten Bögershausen <tboegi@web.de> wrote:
Show 31 quoted lines
> On 2016-03-19 02.19, David Turner wrote:
>> Each write() has syscall overhead, and writing a large index entails
>> many such calls.  A larger write buffer reduces the overhead,
>> leading to increased performance.
>>
>> On my repo, which has an index size of 30m, this saves about 10ms of
>> time writing the index.
>>
>> Signed-off-by: David Turner <dturner@twopensource.com>
>> ---
>>  read-cache.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/read-cache.c b/read-cache.c
>> index d9fb78b..09ebe08 100644
>> --- a/read-cache.c
>> +++ b/read-cache.c
>> @@ -1714,7 +1714,7 @@ int unmerged_index(const struct index_state *istate)
>>       return 0;
>>  }
>>
>> -#define WRITE_BUFFER_SIZE 8192
>> +#define WRITE_BUFFER_SIZE 131072
>>  static unsigned char write_buffer[WRITE_BUFFER_SIZE];
>>  static unsigned long write_buffer_len;
>>
>>
> Do I read that right, it saves 10 milliseconds ?
> What happens to small system (like Raspberry PI), when you
> want 128K write buffer ?
> Could the buffer size be turned into a makefile variable, defaulting to 8192 ?
Maybe for all ARM devices not just Raspberry Pi.

There is one way, though its not that good. This is just a sample code. I am unsure about if using bash in makefile is a good idea

in Makefile,
uname -a | grep "arm" >out
if [ -s out ]; then
    export ARM=arm
fi
rm out
in read-cache.c,
#define ARCH (getenv("ARCH"))
#ifdef ARCH,
    #define WRITE_BUFFER_SIZE 128000
#endif
Previous: Torsten BögershausenNext: Duy Nguyen
Message 3 of 5 in “read-cache: increase write buffer size”
  1. read-cache: increase write buffer sizeDavid Turner, Mar 19, 2016
  2. Torsten BögershausenMar 19, 2016
  3. Pranit BauvaMar 19, 2016
  4. Duy NguyenMar 19, 2016
  5. David TurnerMar 21, 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.