diff options
| -rw-r--r-- | man4/opentracker.conf.4 | 39 | ||||
| -rw-r--r-- | opentracker.conf.sample | 14 | ||||
| -rw-r--r-- | ot_config.c | 2 |
3 files changed, 50 insertions, 5 deletions
diff --git a/man4/opentracker.conf.4 b/man4/opentracker.conf.4 index 2bc1389..b28879f 100644 --- a/man4/opentracker.conf.4 +++ b/man4/opentracker.conf.4 | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | .Dd 2024-04-18 | 1 | .Dd 2026-10-28 |
| 2 | .Dt opentracker.conf 5 | 2 | .Dt opentracker.conf 4 |
| 3 | .Os Unix | 3 | .Os Unix |
| 4 | .Sh NAME | 4 | .Sh NAME |
| 5 | .Nm opentracker.conf | 5 | .Nm opentracker.conf |
| @@ -25,8 +25,29 @@ Specifies the address opentracker will listen on for TCP connections. Can be add | |||
| 25 | .It listen.udp Ar address | 25 | .It listen.udp Ar address |
| 26 | Specifies the address opentracker will listen on for UDP connections. Can be added more than once. | 26 | Specifies the address opentracker will listen on for UDP connections. Can be added more than once. |
| 27 | .Pp | 27 | .Pp |
| 28 | A listen statement may carry options after the address, as in | ||
| 29 | .Dl listen.udp 10.0.0.5:6969 workers=4 shared | ||
| 30 | where | ||
| 31 | .Cm workers Ns = Ns Ar count | ||
| 32 | sets the worker count for that socket alone and is ignored for TCP, and | ||
| 33 | .Cm shared | ||
| 34 | permits another process to bind the same address. | ||
| 35 | .Pp | ||
| 28 | .It listen.udp.workers Ar threads | 36 | .It listen.udp.workers Ar threads |
| 29 | Specifies how many threads will be spawned to handle UDP connections. Defaults to 4. | 37 | Specifies how many threads will be spawned to handle UDP requests, for every |
| 38 | listen statement that does not carry a | ||
| 39 | .Cm workers | ||
| 40 | option of its own. Defaults to 1. A count of 0 serves UDP from the event loop, | ||
| 41 | in the thread that also serves TCP. See | ||
| 42 | .Sx TUNING | ||
| 43 | before raising it. | ||
| 44 | .Pp | ||
| 45 | .It listen.shared Ar boolean | ||
| 46 | Permits another process to bind the same address, for every listen statement | ||
| 47 | that does not carry a | ||
| 48 | .Cm shared | ||
| 49 | option of its own. Defaults to 0, and is useful only where a second tracker is | ||
| 50 | deliberately run on the same address. | ||
| 30 | .Pp | 51 | .Pp |
| 31 | .It access.whitelist Ar path/to/whitelist | 52 | .It access.whitelist Ar path/to/whitelist |
| 32 | Specifies the path to the whitelist file containing all torrent hashes that opentracker will serve. Use this option if opentracker runs in a non-open mode. | 53 | Specifies the path to the whitelist file containing all torrent hashes that opentracker will serve. Use this option if opentracker runs in a non-open mode. |
| @@ -67,6 +88,18 @@ Specifies the user opentracker will setuid to after binding to potentially privi | |||
| 67 | .It tracker.redirect_url Ar URL | 88 | .It tracker.redirect_url Ar URL |
| 68 | Specifies the URL opentracker will redirect to in response to a "GET / HTTP" request. | 89 | Specifies the URL opentracker will redirect to in response to a "GET / HTTP" request. |
| 69 | .El | 90 | .El |
| 91 | .Sh TUNING | ||
| 92 | A worker is a thread that blocks in a read until a datagram arrives. Where the | ||
| 93 | kernel spreads arriving datagrams over a group of sockets bound to one address, | ||
| 94 | opentracker binds one socket per worker and throughput rises with the worker | ||
| 95 | count. Linux does so, and FreeBSD since 12.0. Where a kernel does not, every | ||
| 96 | worker reads the same socket and they contend for its receive queue, so more | ||
| 97 | than one worker costs throughput. opentracker asks at start up and binds a | ||
| 98 | group only where the answer is yes. | ||
| 99 | .Pp | ||
| 100 | .Pa tests/udp_scaling.py | ||
| 101 | in the source distribution sweeps the setting against a running tracker. | ||
| 102 | Measure on the machine that will carry the traffic. | ||
| 70 | .Sh EXAMPLES | 103 | .Sh EXAMPLES |
| 71 | To specify the address opentracker will listen on for both TCP and UDP connections: | 104 | To specify the address opentracker will listen on for both TCP and UDP connections: |
| 72 | .Dl listen.tcp_udp 0.0.0.0:6969 | 105 | .Dl listen.tcp_udp 0.0.0.0:6969 |
diff --git a/opentracker.conf.sample b/opentracker.conf.sample index 4adb736..1d535e8 100644 --- a/opentracker.conf.sample +++ b/opentracker.conf.sample | |||
| @@ -23,7 +23,7 @@ | |||
| 23 | # | 23 | # |
| 24 | # workers=<count> handle this udp socket in blocking reads in that | 24 | # workers=<count> handle this udp socket in blocking reads in that |
| 25 | # many dedicated worker threads instead of in the | 25 | # many dedicated worker threads instead of in the |
| 26 | # event loop. Ignored for tcp. | 26 | # event loop. Defaults to 1. Ignored for tcp. |
| 27 | # shared allow another process to bind the same address and | 27 | # shared allow another process to bind the same address and |
| 28 | # let the kernel share the traffic. Only useful if you | 28 | # let the kernel share the traffic. Only useful if you |
| 29 | # deliberately run a second tracker there. | 29 | # deliberately run a second tracker there. |
| @@ -37,6 +37,18 @@ | |||
| 37 | # listen.udp.workers 4 | 37 | # listen.udp.workers 4 |
| 38 | # listen.shared 1 | 38 | # listen.shared 1 |
| 39 | # | 39 | # |
| 40 | # Raising the worker count pays off where the kernel spreads arriving | ||
| 41 | # datagrams over a group of sockets bound to one address. Linux does so | ||
| 42 | # and FreeBSD has since 12.0, Darwin does not. opentracker asks at start | ||
| 43 | # up and binds one socket per worker only where the answer is yes. Where | ||
| 44 | # it is no, all workers read the one socket and contend for its receive | ||
| 45 | # queue, which costs more than it returns. See the TUNING section of | ||
| 46 | # opentracker.conf(5); tests/udp_scaling.py sweeps the setting on the | ||
| 47 | # machine that will carry the traffic. | ||
| 48 | # | ||
| 49 | # A count of 0 answers udp from the event loop, in the thread that also | ||
| 50 | # serves tcp, which is what opentracker did before. | ||
| 51 | # | ||
| 40 | # Note, that using 0.0.0.0 for udp sockets may yield surprising results. | 52 | # Note, that using 0.0.0.0 for udp sockets may yield surprising results. |
| 41 | # An answer packet sent on that socket will not necessarily have the | 53 | # An answer packet sent on that socket will not necessarily have the |
| 42 | # source address that the requesting client may expect, but any address | 54 | # source address that the requesting client may expect, but any address |
diff --git a/ot_config.c b/ot_config.c index ee6bc12..a0dbef1 100644 --- a/ot_config.c +++ b/ot_config.c | |||
| @@ -32,7 +32,7 @@ const char *g_statefile; | |||
| 32 | static ot_listen *g_listen; | 32 | static ot_listen *g_listen; |
| 33 | static size_t g_listen_count; | 33 | static size_t g_listen_count; |
| 34 | static int g_listen_shared; | 34 | static int g_listen_shared; |
| 35 | static int g_listen_workers; | 35 | static int g_listen_workers = 1; |
| 36 | 36 | ||
| 37 | static void panic(const char *routine) __attribute__((noreturn)); | 37 | static void panic(const char *routine) __attribute__((noreturn)); |
| 38 | static void panic(const char *routine) { | 38 | static void panic(const char *routine) { |
