Skip to content

M1: ncdc and AirDC++ interop, and a 6000-user soak, in CI - #8

Merged
transfix merged 2 commits into
mainfrom
m1-interop-soak
Nov 16, 2026
Merged

transfix merged 2 commits into
mainfrom
m1-interop-soak

Conversation

@transfix

@transfix transfix commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

M1 part 3 of 3: interop and the soak. It is stacked on #7 (the hub), which is stacked on #6. Retarget each as the one below merges.

Clean room. Both clients ran only as black boxes. Neither one's source, nor any other DC implementation's, was opened.

  • ncdc: Ubuntu's ncdc 1.23.1 package, driven through the commands in its man page, ncdc(1).
  • AirDC++: the web client's released portable build, 2.14.0. It was set up with its documented command-line options and driven through its documented HTTP API, using the API Blueprint in airdcpp-web/airdcpp-apidocs.
    • Setting keys came from the running client's own POST /settings/definitions.
    • The API docs point at two AirDC++ source files for the key list. I did not open them.

What's in it

  • server/interop/ncdc_interop.py. It starts the hub alone with its capture on, three ncdc in tmux, and an observer client (tools/nmdc_client.py):

    • ncdcA: active, plain NMDC;
    • ncdcB: active, NMDCS with a self-signed certificate;
    • ncdcC: passive, plain NMDC.

    It checks 17 things:

    1. all three log in;
    2. main chat;
    3. /me;
    4. private messages both ways;
    5. ncdcB (active) downloads ncdcA's file list by $ConnectToMe;
    6. ncdcC (passive) downloads it by $RevConnectToMe, then ncdcA's $ConnectToMe;
    7. an active search reaches the others with the address rewritten, and ncdcB shows ncdcA's result (UDP);
    8. a passive search goes through the hub and ncdcC shows ncdcB's result ($SR through the hub);
    9. the hub's counters show CTM and RCTM;
    10. every $Key matched.

    It writes findings.md from the captures. Locally: 17/17 passed.

  • server/interop/airdcpp_interop.py. The AirDC++ web client logs in in active mode, with an ncdc beside it.

    • Setup:
      • --add-user and --configure take their prompts' answers on stdin, so they work without a terminal;
      • settings go through POST /settings/set;
      • a share root through POST /share_roots;
      • the hub session through POST /hubs with a bare 127.0.0.1:<port>.
    • It checks 16 things:
      1. the session connects and the hub lists the user;
      2. main chat both ways;
      3. a third-person message;
      4. private messages both ways (/private_chat);
      5. a search reaches the others with the address rewritten, and AirDC++ collects ncdc's result (/search/{id}/results);
      6. AirDC++ downloads ncdc's file list (POST /filelists, state loaded);
      7. ncdc downloads AirDC++'s;
      8. $Key matched.
    • Locally and in CI: 16/16 passed.
  • server/interop/soak.py.

    • Worker processes log in N synthetic clients against the hub run alone. The clients send the same login bytes as tools/nmdc_client.py, and each reads everything the hub sends, as a real client must.
    • A probe sends timestamped chat lines (one every 2 s, within the chat limit) and a search every 10 s.
    • Latency is measured at every receiver. It reports the login ramp, the hub's RSS and KiB per user, its CPU, and fan-out latency percentiles.
  • server/tools/run_hub.py. The hub alone on plain asyncio, stdlib only, writing hub.stats() to a file every second.

  • Hub:

    • an opt-in capture, SUBLEVELS_NMDC_CAPTURE_DIR: every message both ways, per connection. It records what clients send in clear, so it is for test hubs only;
    • listen_backlog, default 1024 (below).
  • CI: three new jobs on GitHub-hosted runners:

    • interop-ncdc: apt ncdc tmux;
    • interop-airdcpp: the portable build from web-builds.airdcpp.net, checked against a pinned SHA-256;
    • soak: 6000 users. Both put their results in the job summary and keep the captures and results as artifacts.

Soak, 6000 users (local, Ubuntu 24.04, 32 cores; the hub is one process on one loop)

Online 6000/6000, 0 errors, 0 dropped
Ramp 37 s at 400 logins/s offered; login time p50 4.2 s, p95 19.7 s while the ramp ran
Hub RSS 25 → 126 MiB, 17 KiB per user (buffers included)
Hub CPU 36 s over the ramp, i.e. one core saturated: each login is announced to every user, so logins cost about n²; 2.4 GB were written to clients in the ramp
Chat fan-out to 6000, at every receiver p50 140 ms, p95 262 ms, p99 296 ms, max 324 ms (84,000 receipts)
Search fan-out to 6000 p50 144 ms, p95 270 ms, p99 291 ms (18,000 receipts)
Steady CPU 11.7% of a core for one chat line every 2 s and a search every 10 s, about 0.2 s of CPU per fan-out to 6000 (about 35 µs per connection, mostly the socket write)

For D7. At 6000 users one Python loop sustains roughly 5 fan-outs a second. Searches are capped at 1 per 10 s per user and chat at 5 per 10 s per user. So a hub where only about 1 in 1000 users chats or searches each second stays within that, and anything busier does not.

  • The first soak run lost 147 of 6000 logins: asyncio's default listen backlog of 100 overflowed while the loop was busy with the burst. The hub saw only 5855 connections. With the backlog at 1024 every login succeeds.
  • The answer to M1's "if Python on one loop falls short": it holds 6000 users. Fan-out throughput is the limit, about 30k message writes a second per loop. Per D7, the broadcast and search fan-out are the hot paths to move to native code before M2, if a busy hub needs them. Batching per connection, which already exists, won't help a single fan-out.

To capture: what the captures show (for the spec writer)

From the captures of ncdc 1.23.1 and AirDC++ 2.14.0 (web client). Each item names the spec item it informs.

AirDC++ 2.14.0:

  • P2 login burst.
    • $Supports UserCommand NoGetINFO NoHello UserIP2 TTHSearch ZPipe0 TLS |, with the trailing space before | that P2 §2 allows.
    • Then $Key, $ValidateNick and $Version 1,0091.
    • After $Hello: $GetNickList, then $MyINFO. That is the reverse of ncdc's order.
  • P2 $MyINFO. $MyINFO $ALL airdcpp <AirDC++w V:2.14.0,M:A,H:1/0/0,S:2>$ $0.1S$$2688$. The flag byte is S (0x53): normal, away, TLS and IPv4. A headless web client counts as away. It answers private messages with an automatic "I'm away…" reply, which the hub forwards like any $To.
  • P1 $Key. It matched.
  • P3 /me. A third-person message is sent literally, as <airdcpp> /me waves|, the same as ncdc.
  • P5. It uses the 2-argument $ConnectToMe <remote> <ip>:<port>S|, with the TLS suffix.
  • P4. The active search is $Search 127.0.0.1:<udp> F?T?0?1?interop-ncdca|. No TTH search was sent for a plain query, even though it lists TTHSearch.
  • P7. Not exercised: the AirDC++ run is plain NMDC only.

ncdc 1.23.1:

  • P2 login burst.
    • ncdc sends $Supports NoGetINFO NoHello UserIP2 TLS, $Key, $ValidateNick and $Version 1,0091 in one burst, before $Hello.
    • After $Hello it sends $MyINFO, then $GetNickList.
    • It has both NoHello and NoGetINFO, and logs in with the hub's $Hello, then its own $MyINFO in the list.
  • P2 $MyINFO. $MyINFO $ALL ncdcA <ncdc V:1.23.1,M:A,H:1/0/0,S:10>$ $0.005\x11$$2560$:
    • the description is empty and the tag is the description;
    • the connection field is a number (Mbit/s, "0.005") with no text;
    • the flag is 0x11: normal plus TLS;
    • the email is empty.
  • P1 $Key. Every ncdc key matched P1 §5's algorithm, on every connection (key_mismatch=0). ncdc escapes /%DCN096%/ and others with the DCN scheme.
  • P1 keepalives. None were seen in about 10 s on each connection. The interval stays To capture: it needs a longer run.
  • P3 /me. ncdc sends it literally as main chat: <ncdcB> /me waves|.
  • P3 $To during login. Not exercised. A $To sent while online opens a PM tab named ~observer in ncdc.
  • P5 $ConnectToMe.
    • ncdc uses the 2-argument form, $ConnectToMe <remote> <ip>:<port>S|.
    • The S (TLS) suffix appears even on a plain-NMDC hub when both have TLS in $Supports.
    • In answer to a $RevConnectToMe it sends $ConnectToMe <requester> <ip>:<port>S|.
    • The transfers ran over client-to-client TLS through the hub's rewritten addresses.
  • P5 $RevConnectToMe. $RevConnectToMe ncdcC ncdcA|, the passive user first. No NAT-traversal suffix or feature was seen.
  • P4 $Search.
    • Active: $Search 127.0.0.1:<udp> F?T?0?1?interop-ncdca|. ncdc wrote the right address already, so the rewrite was a no-op.
    • Passive: $Search Hub:ncdcC F?T?0?1?interop-ncdcb|.
    • No TTH (type 9) search was sent for a plain query.
  • P7 nmdcs://.
    • ncdc connects with TLS from the first byte on the NMDCS port.
    • It took the self-signed certificate on first use: the run needed no /accept.
    • The hub then sends $Lock inside TLS, as P7 §1 says.

Not done in this PR

The other "To capture" items need DC++ or EiskaltDC++ (by hand, per the roadmap), AirDC++ over NMDCS, or a longer run (keepalive intervals).

Soak memory per user. It varies between runs: 17 KiB locally, 18 KiB in the first CI run, 6.5 KiB in the second. RSS is sampled once everyone is online, and it includes whatever output is still queued for slow readers at that moment.

@transfix

Copy link
Copy Markdown
Contributor Author

CI (run 43789925454, GitHub-hosted ubuntu-24.04) agrees with the local numbers:

  • interop-ncdc: 17/17.
  • soak, 6000 users:
    • Online: 6000/6000 in 41.6 s at 300 logins/s, with 0 errors and 0 dropped.
    • Login time p50 2.7 s, p95 13.3 s.
    • Hub memory: RSS 26 → 131 MiB, 18 KiB per user.
    • Hub CPU: 40 s over the ramp, and 11.5% of a core in the steady phase.
    • Chat fan-out: p50 137 ms, p95 245 ms, p99 271 ms.
    • Search fan-out: p50 156 ms, p99 268 ms.

The run's summary has the full JSON.

@transfix transfix changed the title M1: ncdc interop and a 6000-user soak, in CI M1: ncdc and AirDC++ interop, and a 6000-user soak, in CI Nov 16, 2026
@transfix

Copy link
Copy Markdown
Contributor Author

Added AirDC++ web client interop (8a7e0b8). The description is updated with its findings.

CI run 43793717697 is green:

  • interop-airdcpp: 16/16.
  • interop-ncdc: 17/17.
  • soak: 6000/6000 online in 27.5 s, hub RSS 25 → 63 MiB.

@transfix
transfix changed the base branch from m1-nmdc-hub to main November 16, 2026 04:44
server/interop/ncdc_interop.py runs ncdc (Ubuntu's package) as a black
box, through its documented commands in tmux: three ncdc (active plain,
active NMDCS, passive) and an observer log in, chat, exchange private
messages, search (active and passive, $SR through the hub) and download
each other's file lists by $ConnectToMe and $RevConnectToMe. The hub's
new opt-in capture (SUBLEVELS_NMDC_CAPTURE_DIR) records every message
both ways; the run writes what it shows for spec/'s "To capture" items.

server/interop/soak.py logs in 6000 synthetic clients against the hub
run alone (tools/run_hub.py, stdlib only) and measures memory per user,
CPU and chat and search fan-out latency at every receiver. The soak
found asyncio's default listen backlog (100) overflowing in a login
burst; the listeners now take listen_backlog (1024).

CI gains interop-ncdc and soak jobs on GitHub-hosted runners.
server/interop/airdcpp_interop.py runs the AirDC++ web client's
portable 2.14.0 release as a black box: set up with its documented
command-line options (--add-user and --configure, answered on stdin)
and driven through its documented HTTP API (the API Blueprint in
airdcpp-web/airdcpp-apidocs), with an ncdc beside it. It checks login
in active mode, main chat both ways and /me, private messages both
ways, search with the address rewrite and the collected result, and
file-list transfers both ways, and writes the To-capture findings.

CI gains an interop-airdcpp job, with the download pinned by SHA-256.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant