splice() per direction, pipes per connection, automatic mode

-s takes the directions to splice: -s1 what the server sends (downloads),
-s2 what the client sends (uploads), -s3 both. -s alone (-s7) splices both
only where it pays, as -s5 and -s6 do for one direction:
- a body of known length is spliced if at least 16K of it is left to read
  once what is already buffered is counted, so an answer read whole with
  its headers is just copied;
- a stream of unknown length starts copied, is spliced after 2 reads in a
  row of at least 16K, and goes back to copying after 3 splices in a row
  of less than 4K, once its pipe is empty.

Pipes are made when a direction first splices and kept with the
connection for its next mappings, so a kept-alive connection no longer
makes and closes two pipes per request; one left holding data by an
error or a timeout is closed. The direction not spliced keeps its buffer.

Before, -s spliced both directions and every mapping made both pipes,
which made small answers slower than without splice: with kept-alive
50K answers 2 pipe2() and 4 close() per request, now none.

Also corrects the default buffer size in the -b help (65536 for TCP).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Vladimir DubrovinandClaude Opus 5.5 committed 2026-10-12 13:58:48 +03:00
1 parent ee5a7588f8
commit b00e3b9a9c
6 files changed
+179 -70

No files matched your search

+11 -6
View File
@@ -203,12 +203,17 @@ delay GRACE_DELAY milliseconds before polling if average polling size is below G
view without ability to reset.
.br
(for TCP services, Linux) use splice() to pass data between the client and the
server without copying it through 3proxy. It is off unless -s is given (-s0 turns
it off explicitly). splice() suits large transfers: they go faster and use less
CPU. Small requests and short connections go slower with it, every connection
needs two more pipes (file descriptors) and more kernel memory, and data filters
are not applied to spliced data. Available in builds with WITHSPLICE, the default
on Linux.
server without copying it through 3proxy. \fB-s\fR alone splices both directions where
it pays: a body of known length if at least 16K of it is left to read, a stream
once it carries large reads, back to copying when they turn small. \fB-s1\fR always
splices what the server sends to the client (downloads), \fB-s2\fR what the client
sends (uploads), \fB-s3\fR both; adding 4 (\fB-s5\fR, \fB-s6\fR, \fB-s7\fR, the last the same as
\fB-s\fR) splices those directions only where it pays. \fB-s0\fR, the default, turns it
off. splice() suits large transfers: they go faster and use less CPU; small
requests go slower with it. A spliced direction needs a pipe (two file
descriptors), made when first needed and kept for the connection, and more
kernel memory; data filters are not applied to spliced data. Available in builds
with WITHSPLICE, the default on Linux.
.br
.B -C
(for TCP services) a connection closed by any of the sides terminates the