commit 3662c36f8b9e00bf7bc822238a379e542b15320e from: Alisdair MacLeod date: Tue Mar 31 18:02:23 2026 UTC Buffer stdout to reduce write(2) syscalls per CGI response CGI route handlers make dozens of small printf/fputs calls. Under the CGI model stdout is piped to the web server and line-buffered by default, so each newline triggers a separate write(2) syscall. Switching to full buffering batches the entire response into one or two writes that flush when the process exits. Co-Authored-By: Claude Opus 4.6 (1M context) commit - 89b827214e68c971373e4ceca0eeb36663ab6b02 commit + 3662c36f8b9e00bf7bc822238a379e542b15320e blob - 8d11358f2c226c6c3c9d113a67c5801b779320fc blob + 648500bf17d5e80bbfe5a0243fdf3522d167598c --- deskd.c +++ deskd.c @@ -134,6 +134,16 @@ main(const int argc, char *argv[]) return 1; } + /* + * Switch stdout to fully buffered mode. CGI route handlers + * make dozens of small printf/fputs calls; without this, each + * newline triggers a write(2) syscall because stdout is + * line-buffered when connected to a pipe. Full buffering + * batches the entire response into one or two writes that + * flush automatically when the process exits. + */ + setvbuf(stdout, NULL, _IOFBF, 0); + if (argc > 1 && strcmp(argv[1], "migrate") == 0) { handle_migrate(); return 0;