about summary refs log tree commit diff
path: root/html.c
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-01-01 13:03:08 +0000
committerRory& <root@rory.gay>2026-02-06 14:09:56 +0100
commit96328c6b1060dc2bbb5d3cc1cb4f2ff8c4521c3a (patch)
tree248c45ebc6014af87a72ca11bef90e4b6ef0bc8d /html.c
parentImprove button spacing for browsers w/o CSS (diff)
downloadcgit-magenta-96328c6b1060dc2bbb5d3cc1cb4f2ff8c4521c3a.tar.xz
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
Diffstat (limited to 'html.c')
-rw-r--r--html.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/html.c b/html.c

index 0bac34b..ced781a 100644 --- a/html.c +++ b/html.c
@@ -80,7 +80,7 @@ char *fmtalloc(const char *format, ...) void html_raw(const char *data, size_t size) { - if (write(STDOUT_FILENO, data, size) != size) + if (fwrite(data, 1, size, stdout) != size) die_errno("write error on html output"); }