-
-
Notifications
You must be signed in to change notification settings - Fork 550
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reduce number of syscalls when sending FastCGI records
Before, for a GET request (no STDIN records): writev(24, [{iov_base="\1\1\0\1\0\10\0\0\0\1\0\0\0\0\0\0\1\4\0\1\1\265\0\0", iov_len=24}, {iov_base="\21\7GATEWAY_INTERFACECGI/1.1\v\tREMO"..., iov_len=437}, {iov_base="\1\4\0\1\0\0\0\0", iov_len=8}], 3) = 469 sendto(24, "\1\5\0\1\0\0\0\0", 8, MSG_DONTWAIT|MSG_NOSIGNAL, NULL, 0) = 8 After, for the same request: writev(24, [{iov_base="\1\1\0\1\0\10\0\0\0\1\0\0\0\0\0\0\1\4\0\1\1\265\0\0", iov_len=24}, {iov_base="\21\7GATEWAY_INTERFACECGI/1.1\v\tREMO"..., iov_len=437}, {iov_base="\1\4\0\1\0\0\0\0", iov_len=8}, {iov_base="\1\5\0\1\0\0\0\0", iov_len=8}], 4) = 477 Gains are a bit better when sending STDIN records, as most of them will be sent with a single writev() syscall. We flush every 16 iovs to avoid inlinefirst array reallocation and keep allocations in the stack as much as we can. (There is a possibility that the last STDIN record after multiple STDIN records might trigger reallocation/copy, but the memory will be freed anyway. This can happen if build_stdin_records() managed to put 16 elements in the iovec_array.)
- Loading branch information
Showing
1 changed file
with
99 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters