test(net): bound Linux blocking-send receiver buffer #8922

Merged
MarcZX10 merged 1 commit from upstream-pr/8922 into main 2026-10-21 19:38:39 +00:00
MarcZX10 commented 2026-10-21 06:14:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T06:14:32Z.


What

Set a small receive buffer on the Linux receiver in the timed-send test. The timeout case deliberately leaves the peer unread; a 1 MiB receive window lets Linux autotune buffer more data than the test's 16 retries expect, so those sends can all make progress. Limiting that test case to 4 KiB makes the peer's receive queue fill predictably and keeps the EAGAIN assertion focused on send timeout behavior. Windows retains its existing buffer setup.

Tested

  • Linux host TCP smoke reproduction with 4 KiB receiver buffer, 4 MiB sends, 100 ms send timeout: first send made partial progress and a later retry timed out within the existing 16-attempt bound.
  • python3 tools/check_conventions.py --base upstream/main --head HEAD passed.
  • git diff --check passed.
  • Not run: full net_dontwait_blocking_{send,sendto,sendmsg} test binaries; this checkout has no configured full build.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: #8917
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4947259934 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8922). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-21T06:14:32Z. --- ### What Set a small receive buffer on the Linux receiver in the timed-send test. The timeout case deliberately leaves the peer unread; a 1 MiB receive window lets Linux autotune buffer more data than the test's 16 retries expect, so those sends can all make progress. Limiting that test case to 4 KiB makes the peer's receive queue fill predictably and keeps the EAGAIN assertion focused on send timeout behavior. Windows retains its existing buffer setup. ### Tested - Linux host TCP smoke reproduction with 4 KiB receiver buffer, 4 MiB sends, 100 ms send timeout: first send made partial progress and a later retry timed out within the existing 16-attempt bound. - `python3 tools/check_conventions.py --base upstream/main --head HEAD` passed. - `git diff --check` passed. - Not run: full `net_dontwait_blocking_{send,sendto,sendmsg}` test binaries; this checkout has no configured full build. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: #8917 - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-21 06:16:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T06:16:03Z.


Disclosure: this overlaps the earlier-open #8918, which also fixes #8917 in NetBlockingSend.cpp by increasing the retry bound. I missed it during my duplicate check. #8918 includes exact Linux and Windows test runs; this PR proposes the alternative of constraining the Linux receiver buffer for the unread-peer timeout case. The two approaches should be compared and only one needs to land.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6309437558 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8922#issuecomment-6309437558). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-21T06:16:03Z. --- Disclosure: this overlaps the earlier-open #8918, which also fixes #8917 in `NetBlockingSend.cpp` by increasing the retry bound. I missed it during my duplicate check. #8918 includes exact Linux and Windows test runs; this PR proposes the alternative of constraining the Linux receiver buffer for the unread-peer timeout case. The two approaches should be compared and only one needs to land.
veosett commented 2026-10-21 08:56:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by veosett on 2026-10-21T08:56:02Z.


Independent Windows/Linux comparison of the two alternatives for #8917: #8918 at aa56b002285182763ac422483bd384d309568ee5 and #8922 at de573c6d1ef287fe20a5e90f728712fef8e3bb0c.

Each unchanged patch was applied separately to the same current main, f894ba69d30055259a56907563f438379d1275a3. The local integration commits were 704bf4ae1ea7b1981df172820b5ec30f6526e8ec for #8918 and 3e1fbde9a8ec0767ce474d0eb28efaf58bb27fba for #8922. Each diff contains only its original NetBlockingSend.cpp change. These are integration results on the newer main, rather than builds of the PRs' older bases.

Release builds succeeded on Ubuntu 24.04 WSL (GCC 13.3) and Windows 11 Pro 10.0.26100 (supported WinLibs GCC 15.2.0 r7).

Blocking-send tests Main, once per test #8918, three repeats per test #8922, three repeats per test
Ubuntu 24.04 WSL All 3 fail: peer never exhausted the send buffers 9/9 pass 9/9 pass
Windows 11 3/3 pass 9/9 pass 9/9 pass

Every candidate run delivered and compared all 4,194,304 payload bytes and passed the existing timeout, abort and guest-nonblocking assertions. There were no skips or CTest timeouts. The longest affected candidate invocation across both hosts and patches was 5.10 s, within the unchanged 20 s timeout.

The eight neighboring net_dontwait_{send,sendto,sendmsg,recv,recvfrom,recvmsg,duplex,blocking} tests and guest_sce_net also passed once each on both hosts, on main and the #8922 integration. Those nine neighbors were not rerun for #8918.

Linux already had the reported limits: net.ipv4.tcp_rmem = 4096 131072 33554432, net.ipv4.tcp_wmem = 4096 16384 4194304, and both net.core.rmem_max and net.core.wmem_max were 4194304. These settings were read without changing them.

ctest --test-dir <build> -R '^net_dontwait_blocking_(send|sendto|sendmsg)$' -V --parallel 1 --repeat until-fail:3
ctest --test-dir <build> -R '^(net_dontwait_(send|sendto|sendmsg|recv|recvfrom|recvmsg|duplex|blocking)|guest_sce_net)$' -V --parallel 1

Main used the same commands without the repeat option. Both alternatives fix the reproduced Linux failure in this environment; only one needs to land. I favor #8922 for this fixture because it explicitly bounds the unread receiver queue in the timeout case, keeping the existing retry budget.

No full suite, macOS, title or console run, and no claim of a production networking change. AI-assisted verification; I ran the builds and tests locally.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6312059871 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8922#issuecomment-6312059871). Originally posted by [veosett](https://github.com/veosett) on 2026-10-21T08:56:02Z. --- Independent Windows/Linux comparison of the two alternatives for #8917: #8918 at `aa56b002285182763ac422483bd384d309568ee5` and #8922 at `de573c6d1ef287fe20a5e90f728712fef8e3bb0c`. Each unchanged patch was applied separately to the same current `main`, `f894ba69d30055259a56907563f438379d1275a3`. The local integration commits were `704bf4ae1ea7b1981df172820b5ec30f6526e8ec` for #8918 and `3e1fbde9a8ec0767ce474d0eb28efaf58bb27fba` for #8922. Each diff contains only its original `NetBlockingSend.cpp` change. These are integration results on the newer main, rather than builds of the PRs' older bases. Release builds succeeded on Ubuntu 24.04 WSL (GCC 13.3) and Windows 11 Pro 10.0.26100 (supported WinLibs GCC 15.2.0 r7). | Blocking-send tests | Main, once per test | #8918, three repeats per test | #8922, three repeats per test | | --- | --- | --- | --- | | Ubuntu 24.04 WSL | All 3 fail: `peer never exhausted the send buffers` | 9/9 pass | 9/9 pass | | Windows 11 | 3/3 pass | 9/9 pass | 9/9 pass | Every candidate run delivered and compared all 4,194,304 payload bytes and passed the existing timeout, abort and guest-nonblocking assertions. There were no skips or CTest timeouts. The longest affected candidate invocation across both hosts and patches was 5.10 s, within the unchanged 20 s timeout. The eight neighboring `net_dontwait_{send,sendto,sendmsg,recv,recvfrom,recvmsg,duplex,blocking}` tests and `guest_sce_net` also passed once each on both hosts, on main and the #8922 integration. Those nine neighbors were not rerun for #8918. Linux already had the reported limits: `net.ipv4.tcp_rmem = 4096 131072 33554432`, `net.ipv4.tcp_wmem = 4096 16384 4194304`, and both `net.core.rmem_max` and `net.core.wmem_max` were 4194304. These settings were read without changing them. ```sh ctest --test-dir <build> -R '^net_dontwait_blocking_(send|sendto|sendmsg)$' -V --parallel 1 --repeat until-fail:3 ctest --test-dir <build> -R '^(net_dontwait_(send|sendto|sendmsg|recv|recvfrom|recvmsg|duplex|blocking)|guest_sce_net)$' -V --parallel 1 ``` Main used the same commands without the repeat option. Both alternatives fix the reproduced Linux failure in this environment; only one needs to land. I favor #8922 for this fixture because it explicitly bounds the unread receiver queue in the timeout case, keeping the existing retry budget. No full suite, macOS, title or console run, and no claim of a production networking change. AI-assisted verification; I ran the builds and tests locally.
00xDisaster commented 2026-10-21 13:53:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by 00xDisaster on 2026-10-21T13:53:46Z.


Independent Linux validation of this exact branch (de573c6d1): GCC 16.2.1, Release, x86-64. I rebuilt net_blocking_send_tests and ran the full trio:

100% tests passed, 0 tests failed out of 3
net_dontwait_blocking_send ........ 2.66 s
net_dontwait_blocking_sendto ...... 2.65 s
net_dontwait_blocking_sendmsg ..... 2.76 s
python3 tools/check_conventions.py --base upstream/main also passes. This covers the full test binaries noted as not run in the PR description.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6317814268 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8922#issuecomment-6317814268). Originally posted by [00xDisaster](https://github.com/00xDisaster) on 2026-10-21T13:53:46Z. --- Independent Linux validation of this exact branch (`de573c6d1`): GCC 16.2.1, Release, x86-64. I rebuilt `net_blocking_send_tests` and ran the full trio: ```text 100% tests passed, 0 tests failed out of 3 net_dontwait_blocking_send ........ 2.66 s net_dontwait_blocking_sendto ...... 2.65 s net_dontwait_blocking_sendmsg ..... 2.76 s python3 tools/check_conventions.py --base upstream/main also passes. This covers the full test binaries noted as not run in the PR description.
rooklz commented 2026-10-21 18:35:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by rooklz on 2026-10-21T18:35:00Z.


I looked into why these three started failing on GitHub-hosted runners, since every hosted test run of a PR hits them now. Two things that may help whichever of #8918 and this one lands:

The trigger is the runner kernel, not tcp_rmem autotuning. The ubuntu-24.04 image my fork's runs got (20261018.339) is the first on kernel 7.0.0-1017-azure. Since Linux 6.18 (a6d4f25888b8), net.core.rmem_max defaults to 4 MiB instead of 208 KiB. The test sets the receiver's SO_RCVBUF to 1 MiB after accept. Linux caps the request at rmem_max and doubles it, so it used to end up at 416 KiB and now takes full effect at 2 MiB. Setting SO_RCVBUF also turns autotuning off, so tcp_rmem plays no part: with its maximum at 32 MiB nothing changed. The peer fills slowly because the window never scales (the listener's 4 KiB buffer is set before the handshake) and an unread receiver acknowledges only on its delayed-ACK timer. Each 100 ms send then moves 64 to 98 KiB and returns partial. With the 2 MiB buffer the first EAGAIN came on attempt 22 in 3 of 3 runs, so 16 attempts aren't enough and 64 happen to be. With the receiver at 4 KiB, as here, the second timed send returns EAGAIN. I measured this in an x86-64 container under Rosetta on a Linux 6.8 VM, emulating the larger limit with a preload shim that turns SO_RCVBUF into SO_RCVBUFFORCE. With the shim, the real net_blocking_send_tests fails 3 of 3 with "peer never exhausted the send buffers"; without it the test passes.

The abort block has a separate race that neither PR touches. It aborts after a fixed 50 ms wait, but nothing checks that the send has reached the host by then. In one trace shutdown ran 122 ms before sendto started, so the send got EPIPE and the test failed with "error discarded queued bytes". On hosted runners this never shows because the second block fails first. With this PR's change alone I saw it in 3 of 36 local runs. Waiting until the receiver can peek a byte before the 50 ms check fixed it for me:

         auto sending = std::async(std::launch::async, [&] { return Send(api, connection.sender, bytes); });
+        const auto entered = std::chrono::steady_clock::now() + std::chrono::seconds(5);
+        char peeked = 0;
+        while (sceNetRecv(connection.receiver, &peeked, 1, NET_MSG_PEEK | NET_MSG_DONTWAIT) <= 0 && std::chrono::steady_clock::now() < entered)
+            std::this_thread::sleep_for(std::chrono::milliseconds(1));
         Require(sending.wait_for(std::chrono::milliseconds(50)) == std::future_status::timeout, "send did not wait before abort");

With that, this PR's SO_RCVBUF line, and an 8 s deadline in place of the 16 attempts, the three tests passed 36 of 36 runs, at the stock limit and with the shim. The deadline is optional; with the 4 KiB receiver the loop ends on its second send anyway.

I'm happy for the peek to go into this PR or into a follow-up after it, whichever you prefer. I won't open a competing PR for the same file.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6323608901 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8922#issuecomment-6323608901). Originally posted by [rooklz](https://github.com/rooklz) on 2026-10-21T18:35:00Z. --- I looked into why these three started failing on GitHub-hosted runners, since every hosted test run of a PR hits them now. Two things that may help whichever of #8918 and this one lands: **The trigger is the runner kernel, not `tcp_rmem` autotuning.** The ubuntu-24.04 image my fork's runs got (`20261018.339`) is the first on kernel `7.0.0-1017-azure`. Since Linux 6.18 (`a6d4f25888b8`), `net.core.rmem_max` defaults to 4 MiB instead of 208 KiB. The test sets the receiver's `SO_RCVBUF` to 1 MiB after accept. Linux caps the request at `rmem_max` and doubles it, so it used to end up at 416 KiB and now takes full effect at 2 MiB. Setting `SO_RCVBUF` also turns autotuning off, so `tcp_rmem` plays no part: with its maximum at 32 MiB nothing changed. The peer fills slowly because the window never scales (the listener's 4 KiB buffer is set before the handshake) and an unread receiver acknowledges only on its delayed-ACK timer. Each 100 ms send then moves 64 to 98 KiB and returns partial. With the 2 MiB buffer the first `EAGAIN` came on attempt 22 in 3 of 3 runs, so 16 attempts aren't enough and 64 happen to be. With the receiver at 4 KiB, as here, the second timed send returns `EAGAIN`. I measured this in an x86-64 container under Rosetta on a Linux 6.8 VM, emulating the larger limit with a preload shim that turns `SO_RCVBUF` into `SO_RCVBUFFORCE`. With the shim, the real `net_blocking_send_tests` fails 3 of 3 with "peer never exhausted the send buffers"; without it the test passes. **The abort block has a separate race that neither PR touches.** It aborts after a fixed 50 ms wait, but nothing checks that the send has reached the host by then. In one trace `shutdown` ran 122 ms before `sendto` started, so the send got `EPIPE` and the test failed with "error discarded queued bytes". On hosted runners this never shows because the second block fails first. With this PR's change alone I saw it in 3 of 36 local runs. Waiting until the receiver can peek a byte before the 50 ms check fixed it for me: ```diff auto sending = std::async(std::launch::async, [&] { return Send(api, connection.sender, bytes); }); + const auto entered = std::chrono::steady_clock::now() + std::chrono::seconds(5); + char peeked = 0; + while (sceNetRecv(connection.receiver, &peeked, 1, NET_MSG_PEEK | NET_MSG_DONTWAIT) <= 0 && std::chrono::steady_clock::now() < entered) + std::this_thread::sleep_for(std::chrono::milliseconds(1)); Require(sending.wait_for(std::chrono::milliseconds(50)) == std::future_status::timeout, "send did not wait before abort"); ``` With that, this PR's `SO_RCVBUF` line, and an 8 s deadline in place of the 16 attempts, the three tests passed 36 of 36 runs, at the stock limit and with the shim. The deadline is optional; with the 4 KiB receiver the loop ends on its second send anyway. I'm happy for the peek to go into this PR or into a follow-up after it, whichever you prefer. I won't open a competing PR for the same file.
adriadam10 commented 2026-10-21 19:39:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-21T19:39:59Z.


Checked the 4 KiB receive buffer on the unread-peer timeout case (Linux only, Windows unchanged), the option constants used by the file, and the independent Linux/Windows runs by @veosett and @00xDisaster (main fails 3/3 on Linux, this head passes); merged. This supersedes #8918, which fixes the same #8917 with a different approach.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6324897803 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8922#issuecomment-6324897803). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-21T19:39:59Z. --- Checked the 4 KiB receive buffer on the unread-peer timeout case (Linux only, Windows unchanged), the option constants used by the file, and the independent Linux/Windows runs by @veosett and @00xDisaster (main fails 3/3 on Linux, this head passes); merged. This supersedes #8918, which fixes the same #8917 with a different approach.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!8922
No description provided.