mirror of
https://github.com/3proxy/3proxy.git
synced 2026-11-22 23:59:41 +08:00
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:
1 parent
c13c048f3f
commit
626aac16bc
6 files changed
+179
-70
No files matched your search
@@ -34,7 +34,7 @@ Each connected client requires:
|
||||
<ul>
|
||||
<li>1 thread (process)
|
||||
<li>2 sockets (file descriptors). For FTP, 4 sockets are required.
|
||||
<br>With splice() (Linux, -s), 2 more pipes (file descriptors) = 4 file descriptors, 6 for FTP.
|
||||
<br>With splice() (Linux, -s), a pipe (2 file descriptors) for each spliced direction: up to 4 more file descriptors, 6 for FTP.
|
||||
<br>Up to 128K (up to 256K with splice()) of kernel buffer memory. This is the theoretical maximum; actual numbers depend on connection quality and traffic amount.
|
||||
<br>1 additional socket (file descriptor) during name resolution for non-cached names
|
||||
<br>1 additional socket during authentication or logging for RADIUS authentication or logging.
|
||||
@@ -664,15 +664,20 @@ include it, but a service uses it only when given the -s option:
|
||||
<pre>
|
||||
proxy -s
|
||||
socks -s
|
||||
tcppm -s 8080 192.168.1.1 80
|
||||
tcppm -s3 8080 192.168.1.1 80
|
||||
</pre>
|
||||
-s0 turns it off explicitly. In builds without it (CMake option 3PROXY_USE_SPLICE=OFF,
|
||||
-s alone splices both directions where it pays: an HTTP body of known length if at
|
||||
least 16K of it is left to read, a stream (CONNECT, SOCKS, tcppm) once it carries
|
||||
large reads, going back to copying when they turn small. -s1 always splices what the
|
||||
server sends to the client (downloads), -s2 what the client sends to the server
|
||||
(uploads), -s3 both; -s5, -s6 and -s7 (the same as -s) do it for those directions
|
||||
only where it pays. -s0, the default, turns it off. In builds without it (CMake option 3PROXY_USE_SPLICE=OFF,
|
||||
or -DWITHSPLICE removed from the Makefile) -s is accepted and ignored.
|
||||
<p>splice() pays off when most of the traffic is large transfers: in the
|
||||
<a href="https://github.com/3proxy/3proxy/blob/master/bench/RESULTS.md">benchmarks</a> it moved
|
||||
1.3 to 2.1 times more data than the read/write path at 40-55% less CPU per gigabyte.
|
||||
It does not help small requests and short connections, which go slower with it, and
|
||||
every spliced connection needs two more pipes (file descriptors) and more kernel
|
||||
every spliced direction needs a pipe (two file descriptors) and more kernel
|
||||
buffer memory. Data filters are not applied to spliced data.
|
||||
<p>TCP_NODELAY and splice() do not conflict and can be combined on high-speed connections.
|
||||
|
||||
|
||||
Reference in new issue
Block a user