mirror of
https://github.com/3proxy/3proxy.git
synced 2026-11-22 23:59:41 +08:00
Clients of TCP services on event loops, served by fibers
With -L, or loopmode on for the services which follow, the clients of a TCP service are served on event loops: loops threads (by default one for each CPU) each run a loop, and each client is given in turn to one of them, which serves it on a fiber with the same code a thread runs. Its waits in sockpoll() wait in the loop, its sockets and a timer registered there, and the fiber goes on once one is ready or the time is out; a sleep is a timer alone. A client costs a stack, as large as its thread's would be, and no thread. The loops start with the first client served on one and run as long as the process; each keeps up to 256 idle fibers for its next clients. srvspawn() posts the client to its loop once it is counted, what is posted made before so that posting cannot fail. A service whose clients cannot share a thread (threadperclient), or listening for connections back (-R), all of its clients waiting for one socket, which a loop waits for once, keeps a thread for each client, as does every service of a build or a processor without fibers, and the standalone services. tests/run.py --loopmode runs every configuration with loopmode on, on two loops. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e250f98598
commit
c55f736a0d
11 files changed
+489
-20
No files matched your search
+3
-1
@@ -179,7 +179,9 @@ class Tester:
|
||||
|
||||
def write_config(self, name, config):
|
||||
path = os.path.join(self.tmpdir, name + ".cfg")
|
||||
text = textwrap.dedent(config).strip() + "\n"
|
||||
# run.py --loopmode: every configuration starts with what it gives
|
||||
text = os.environ.get("THREEPROXY_TESTCONFIG", "") + \
|
||||
textwrap.dedent(config).strip() + "\n"
|
||||
# newline="" keeps the line endings as written, rather than letting
|
||||
# Windows turn them into CRLF behind the parser's back
|
||||
with open(path, "w", newline="") as fp:
|
||||
|
||||
@@ -58,7 +58,11 @@ def main():
|
||||
help="keep the temporary directory")
|
||||
parser.add_argument("-v", "--verbose", action="store_true",
|
||||
help="print every check, not just the failures")
|
||||
parser.add_argument("--loopmode", action="store_true",
|
||||
help="serve the clients of every service on event loops")
|
||||
args = parser.parse_args()
|
||||
if args.loopmode:
|
||||
os.environ["THREEPROXY_TESTCONFIG"] = "loops 2\nloopmode on\n"
|
||||
|
||||
binary = args.binary or os.environ.get("BIN") or default_binary()
|
||||
binary = os.path.abspath(binary)
|
||||
|
||||
Reference in new issue
Block a user