Repository navigation
fix(server): raise the open-file limit at start, and say when accepts run out of descriptors - #294
Closed
plotarmordev wants to merge 1 commit into
Closed
plotarmordev wants to merge 1 commit into
plotarmordev wants to merge 1 commit into
Conversation
… run out of descriptors With Docker's default 1024 descriptors an idle Flash Next server already holds 427, so about 600 idle connections exhaust the rest. accept() then fails with EMFILE, and socketserver drops that error without a word: clients hang, the log stays empty, and the accept loop spins a core at 100% (ashhart#293). The server now raises its soft RLIMIT_NOFILE to the hard limit at start. When accept() still fails for want of descriptors it prints one line for the run (again after the next accept succeeds) and waits 0.1 s before the next try. Both servers share Server, so this covers the Mac and CUDA servers.
Closed
ashhart
added a commit
that referenced
this pull request
Oct 6, 2026
…runs out of descriptors From PR #294. Before it listens, the server raises its soft RLIMIT_NOFILE to the hard limit, so idle keep-alive connections cannot exhaust a default of 256 or 1024. When the hard limit reads as unlimited it tries 65536, then 10240, and never sets an unlimited soft limit. A limit already high enough is left alone, a refused raise keeps the current one, and a raise logs the old and new values. When accept fails for lack of descriptors (EMFILE or ENFILE), the listener logs one line per burst, naming the error and saying to raise ulimit -n, and keeps its 10 ms backoff. zig build test now runs the server's unit tests (zig/src/server/root.zig), including a raise from a lowered soft limit and the once-per-burst rule. Co-authored-by: plotarmordev <[email protected]>
Owner
|
Thank you, @plotarmordev. This landed in the Zig engine as 267cd3c, with your credit. The Zig server never had the spin, since its accept loop already backed off for 10 ms when descriptors ran out. It lacked your other two pieces and now has both. At start it raises the soft open-file limit to the hard limit, with your 65536 and 10240 fallbacks when the hard limit reads as unlimited. macOS reports it that way, so the Mac path you couldn't test is the one that runs there. When accept still runs out of descriptors, the server logs one line a burst instead of retrying quietly. That covers what you reported in #293, which closes with this. The Python engine is frozen (#286), so this PR closes with that. Thanks for the clear repro on a GB10. |
grearjake-star
added a commit
to grearjake-star/TensorFold
that referenced
this pull request
Oct 8, 2026
…out of descriptors With the default soft limit of 1024 descriptors the server silently stopped accepting connections at about 600 idle keep-alive connections: new connects sat in the backlog, requests hung, nothing was logged and the accept loop spun a core. The server now raises its soft RLIMIT_NOFILE to the hard limit at start, and when accept() still fails for want of descriptors it prints one line for the burst and waits 0.1 s before the next try. The CUDA server uses this Server class. Upstream: ashhart#294 (fixes ashhart#293), closed unmerged with the Python engine frozen; the maintainer landed the same two pieces in the Zig server. Co-authored-by: plotarmordev <[email protected]>
Bizuayeu
added a commit
to Bizuayeu/TensorFold
that referenced
this pull request
Oct 12, 2026
…erver listens With a container's default 1024 descriptors, idle connections can use up the rest, and the server then waits on every accept. The listener already said so once a burst and backed off; it now also raises the soft RLIMIT_NOFILE to the hard limit when it opens (65536, then 10240, when the hard limit is unlimited), as the 2.x line has done since 2.5.0 (TensorFold ashhart#294 by plotarmordev). A failure to raise it leaves the limit as it was.
8 tasks done
Bizuayeu
added a commit
to Bizuayeu/TensorFold
that referenced
this pull request
Oct 13, 2026
…erver listens With a container's default 1024 descriptors, idle connections can use up the rest, and the server then waits on every accept. The listener already said so once a burst and backed off; it now also raises the soft RLIMIT_NOFILE to the hard limit when it opens (65536, then 10240, when the hard limit is unlimited), as ashhart#294 (by plotarmordev) did for the Python engine. A failure to raise it leaves the limit as it was.
Bizuayeu
added a commit
to Bizuayeu/TensorFold
that referenced
this pull request
Oct 13, 2026
…erver listens With a container's default 1024 descriptors, idle connections can use up the rest, and the server then waits on every accept. The listener already said so once a burst and backed off; it now also raises the soft RLIMIT_NOFILE to the hard limit when it opens (65536, then 10240, when the hard limit is unlimited), as ashhart#294 (by plotarmordev) did for the Python engine. A failure to raise it leaves the limit as it was.
BlivionIaG
pushed a commit
to BlivionIaG/TensorFold
that referenced
this pull request
Oct 20, 2026
…runs out of descriptors From PR ashhart#294. Before it listens, the server raises its soft RLIMIT_NOFILE to the hard limit, so idle keep-alive connections cannot exhaust a default of 256 or 1024. When the hard limit reads as unlimited it tries 65536, then 10240, and never sets an unlimited soft limit. A limit already high enough is left alone, a refused raise keeps the current one, and a raise logs the old and new values. When accept fails for lack of descriptors (EMFILE or ENFILE), the listener logs one line per burst, naming the error and saying to raise ulimit -n, and keeps its 10 ms backoff. zig build test now runs the server's unit tests (zig/src/server/root.zig), including a raise from a lowered soft limit and the once-per-burst rule. Co-authored-by: plotarmordev <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
Fixes #293. The server raises its soft open-file limit (
RLIMIT_NOFILE) to the hard limit at start, so idle connections can't exhaust a default 1024. Whenaccept()still fails for want of descriptors, it prints one line for the run and waits 0.1 s before the next try. Before,socketserverdropped theEMFILEsilently and the accept loop spun a core at 100 %. Both servers shareServer; the new code is inserver/descriptors.py.Receipt
Environment: TensorFold 0.6.3 (9356df5), PyTorch 2.13.0a0, one DGX Spark (GB10, CUDA 13.3, driver 580), Vontra/Qwen3.8-Flash-Next-MLX-4bit-MTP @ dadefa80,
--parallel 1 --context 16384, in Docker. Idle keep-alive connections opened in steps of 50 up to 900, then one chat request, then the connections closed and one more request.--ulimit nofile=1024:1024--ulimit nofile=1024:1024The log line:
[tensorfold] out of file descriptors (Too many open files): new connections wait until open ones close; raise the open-file limit (ulimit -n). In every case the next request after the connections close answers in 0.1-0.4 s.Exactness: not applicable. Replies don't go through this code.
Decode speed: not applicable.
Prompt speed: not applicable.
Tests run:
tests/test_server_descriptors.py, in subprocesses (process-wide limits). A server started with soft limit 256 raises it to the hard limit. An accept refused for want of descriptors prints once per run and again after the next accept succeeds. Both fail at 0.6.3 and pass with this change.tests/test_server*.py tests/test_cuda_server*.pyon CPU: 318 passed, 1 skipped (0.6.3 with the new file: 316 passed, the 2 new tests failed).Not run, and why: the Mac server.
resourceexists on macOS; when the hard limit is unlimited it tries 65536, then 10240, and keeps the current limit if neither is allowed. I have no Mac to check that path. Windows has noresourceand is unchanged.Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo.