read-cache: increase write buffer size
PATCH 1/1 read-cache: increase write buffer size
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.
--- read-cache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
read-cache.c +1 -1
@@ -1714,7 +1714,7 @@ int unmerged_index(const struct index_state *istate)return 0 ; } -#define WRITE_BUFFER_SIZE 8192 +#define WRITE_BUFFER_SIZE 131072static unsigned char write_buffer[WRITE_BUFFER_SIZE ];static unsigned long write_buffer_len;
Signature · 1 line
2.4.2.767.g62658d5-twtrsrc
Quoted 18 lines · David Turner
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 <[email protected]>--- read-cache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)read-cache.c +0
-0
read-cache.c int unmerged_index(const struct index_state *istate) · line 1720
Quoted 8 lines
read-cache.c +1
-1@@ -1714,7 +1714,7 @@ int unmerged_index(const struct index_state *istate)return 0 ; } -#define WRITE_BUFFER_SIZE 8192 +#define WRITE_BUFFER_SIZE 131072static 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 ?
Quoted 21 lines · Torsten Bögershausen
Quoted 20 lines · David Turner
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 <[email protected]>--- read-cache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)read-cache.c +0
-0@@ -1714,7 +1714,7 @@ int unmerged_index(const struct index_state *istate)return 0 ; }
Quoted 10 lines
read-cache.c int unmerged_index(const struct index_state *istate) · line 1720
Quoted 6 lines
read-cache.c +1
-1-#define WRITE_BUFFER_SIZE 8192 +#define WRITE_BUFFER_SIZE 131072static 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
Quoted 6 lines · David Turner
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.
I wonder if split-index does not work as intended. Because if it does, you should rarely need to write that such big index files (or is this 30mb the small part and the base index is even bigger?).
But I agree with Torsten that we should make this configurable, preferably via config file, if not we can still move this define back in Makefile, overridable using config.mak
Signature · 1 line
Duy
Quoted 11 lines · Duy Nguyen
Quoted 8 lines · David Turner
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.
Quoted 8 lines
I wonder if split-index does not work as intended. Because if it does,
you should rarely need to write that such big index files (or is this 30mb the small part and the base index is even bigger?).But I agree with Torsten that we should make this configurable, preferably via config file, if not we can still move this define back in
Makefile, overridable using config.mak
Oh, right, split index. Yeah, I should just turn that on. Nevermind.