about summary refs log tree commit
path: root/ui-snapshot.c
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-01-01 13:03:08 +0000
committerEric Wong <e@80x24.org>2019-04-22 02:34:37 +0000
commit085cb2517b98cea23aa5ec5f57e1022bf4653616 (patch)
tree67d25e3efa7884c2c7c4340647e4f8274dba192e /ui-snapshot.c
parenta99c866cc8ef91ea366f536cc3125ed4647c6d79 (diff)
downloadcgit-085cb2517b98cea23aa5ec5f57e1022bf4653616.tar.gz
use buffered stdio (lightly tested)
Our generation of HTML triggers many small write(2) syscalls
which is inefficient.

Time output on a horrible query against my git.git mirror
shows significant performance improvement:

QUERY_STRING='id=2b93bfac0f5bcabbf60f174f4e7bfa9e318e64d5&id2=d6da71a9d16b8cf27f9d8f90692d3625c849cbc8'
PATH_INFO=/mirrors/git.git/diff
export QUERY_STRING PATH_INFO
time ./cgit >/dev/null

Before:
real    0m1.585s
user    0m0.904s
sys     0m0.658s

After:
real    0m0.750s
user    0m0.666s
sys     0m0.076s
Diffstat (limited to 'ui-snapshot.c')
-rw-r--r--ui-snapshot.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/ui-snapshot.c b/ui-snapshot.c
index 9461d51..b9f03de 100644
--- a/ui-snapshot.c
+++ b/ui-snapshot.c
@@ -37,6 +37,9 @@ static int write_archive_type(const char *format, const char *hex, const char *p
         /* argv_array guarantees a trailing NULL entry. */
         memcpy(nargv, argv.argv, sizeof(char *) * (argv.argc + 1));
 
+        if (fflush(stdout))
+                return errno;
+
         result = write_archive(argv.argc, nargv, NULL, the_repository, NULL, 0);
         argv_array_clear(&argv);
         free(nargv);