From 1cd637cd1f637aa8aa1c2d416ae01ee31b3a691c Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 21 May 2026 15:11:10 +0200 Subject: use buffered stdio 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 Signed-off-by: Eric Wong Signed-off-by: Alyssa Ross --- ui-snapshot.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'ui-snapshot.c') diff --git a/ui-snapshot.c b/ui-snapshot.c index d157222..b3039d9 100644 --- a/ui-snapshot.c +++ b/ui-snapshot.c @@ -39,6 +39,9 @@ static int write_archive_type(const char *format, const char *hex, const char *p /* strvec guarantees a trailing NULL entry. */ memcpy(nargv, argv.v, sizeof(char *) * (argv.nr + 1)); + if (fflush(stdout)) + return errno; + result = write_archive(argv.nr, nargv, NULL, the_repository, NULL, 0); strvec_clear(&argv); free(nargv); -- cgit v1.2.3