Make the automatic splice() mode's heuristics a service option

-s[N]:MIN,STREAK,SMALL sets where the automatic mode splices, as -g
does for grace delay: a direction is spliced after STREAK reads in a
row of MIN bytes or more (SMALL from a TLS socket), copied again after
more than STREAK splices in a row of less than SMALL, and a body of
known length is spliced if MIN or more of it is left. The defaults,
16384,2,4096, are what was built in; a value left out or 0 keeps its
default.

The man page describes it, and its HTML copy, which still said splice()
was not built by default, now has the current text. A test case relays
answers of every size, chunked ones and a 3 MB upload through every
mode, two of them with heuristics set, and compares them byte for byte.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Vladimir DubrovinandClaude Opus 5.5 committed 2026-10-14 19:02:23 +03:00
1 parent cfe52878d0
commit 61041ebe7d
7 files changed
+207 -32

No files matched your search

+27 -6
View File
@@ -218,12 +218,33 @@ second. Useful to minimize polling <b><br>
-s</b> <br>
(for admin) secure, allow only secure operations, currently
only traffic counters view without ability to reset. <br>
(for TCP services, Linux) enable splice(). splice() is not
built by default and is disabled even when built, because
current Linux does not implement SPLICE_F_MOVE, so no real
zero-copy takes place and the read/write path is faster for
most traffic. Rebuild with -DWITHSPLICE to make -s
available, -s0 disables it explicitly. <b><br>
(for TCP services, Linux) use splice() to pass data between
the client and the server without copying it through 3proxy.
<b>-s</b> 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. <b>-s1</b> always splices what the server sends
to the client (downloads), <b>-s2</b> what the client sends
(uploads), <b>-s3</b> both; adding 4 (<b>-s5</b>, <b>-s6</b>,
<b>-s7</b>, the last the same as <b>-s</b>, and the default)
splices those directions only where it pays. <b>-s0</b> turns
it off. Where it pays can be tuned with
<b>:</b><i>MIN</i><b>,</b><i>STREAK</i><b>,</b><i>SMALL</i>
after the mode, e.g. <b>-s:16384,2,4096</b> (the default) or
<b>-s6:65536,3,8192</b>: a direction is spliced after
<i>STREAK</i> reads in a row of <i>MIN</i> bytes or more
(<i>SMALL</i> from a TLS socket, which hands out a record at a
time) and copied again after more than <i>STREAK</i> splices
in a row of less than <i>SMALL</i>; a body of known length is
spliced if at least <i>MIN</i> of it is left to read. splice()
suits large transfers: they go faster and use less CPU. A
spliced direction needs a pipe (two file descriptors), made
when first needed and kept for the connection, and more kernel
memory. A service with data filters does not splice, so that
the filters see all of the data, nor does one ending or
beginning TLS, unless the kernel does TLS for it both ways
(<b>ssl_ktls</b>). Available in builds with WITHSPLICE, the
default on Linux. <b><br>
-C</b> <br>
(for TCP services) a connection closed by any of the sides
terminates the session, buffered data is delivered before