Repository navigation
Conversation
…dline (#4173) `runRpHttpRequestTest` drained each response with const uint32_t deadline_ms = millis() + 2000; while (millis() - deadline_ms < 0 && (client.connected() || client.available())) so it exited on the 2 s deadline or on the peer closing. The request does ask for `Connection: close`, but `client.connected()` does not go false promptly enough to end the read, so the loop waited out the remaining deadline on every request after the body had already arrived. `runNetClientTest` issues 12 requests, which is ~2.2 s each and the 26.57 s measured on hardware -- almost all of it idle. The caller allows `max_wait=30.0` and the peer cycle makes two such calls, so the run had ~3.4 s of headroom on a healthy first cycle. That is the pressure behind #4173: an operation marginal from the start rather than a resource that exhausts itself at cycle 7. Stop on completeness instead: parse the headers, capture Content-Length, read exactly that many body bytes, then break without consulting the connection state. The 2 s deadline stays as the ceiling for a server that never replies, and the body is drained past the buffer so the socket is not abandoned mid-response. Also separates headers from body. `response[256]` held both, so a response with long headers could push the asserted fragment out of the window entirely -- a failure mode independent of timing. Measured on hardware (RP2350W <-> ESP32-C6 SoftAP), 9 cycles: before: 26.57 s per runNetClientTest after: 8.1 - 20.4 s, 6/9 cycles fully passing focused: 3/3 cycles at 12/12 sub-tests NOT yet validated against a baseline pass rate. The one pre-change data point I have is a single ok=True cycle, which says nothing about how the unmodified build scores over nine. The comparison run was cut short by host memory pressure, and since the harness itself fails at cycle 7 the baseline may be flaky too. Do not merge this on the timing alone. bash lint clean; rp2350w builds and passes RPC smoke. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01KkufoNxfnNRU9psT3R9F51
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Closing — the baseline comparison I flagged as missing has now been run, and it rejects this change.
Same probe, same C6 SoftAP, same nine cycles. The unmodified build is 100% reliable and near-deterministic — which makes sense in hindsight: waiting out a fixed 2 s per request is slow, but it is also completely insensitive to when data actually arrives. So 6/9 is not "equal correctness at 2.3x the speed". It is flakiness I introduced, and this PR would trade a slow-but-correct path for a fast-but-unreliable one. Same verdict as my earlier 150 ms idle-stop attempt (2.8x faster, 1/8 passing), for the same underlying reason. The 12.3 s spread is the tell. If Content-Length parsing were working on every response, timings would cluster. They do not, which suggests some responses on this path do not carry a usable The root-cause analysis stands and is worth keeping (recorded in #4173):
One thing the baseline run also settles: at 26.8 s the content checks pass every time, so the cycle-7 failure in Not merging this. The header/body separation in it is independently correct and could be salvaged, but it should not ride along with the completion logic that is not right yet. |
Addresses the root cause found in #4173. Please do not merge on the timing improvement alone — see Validation gap below.
Root cause
runRpHttpRequestTestdrained each response like this:It exits on the 2 s deadline or on the peer closing. The request does send
Connection: close, butclient.connected()does not go false promptly enough to end the read — so the loop waits out the remaining deadline on every request, after the body has already arrived.runNetClientTestissues 12 requests. That is ~2.2 s each and the 26.57 s measured on hardware, almost all of it idle. The caller allowsmax_wait=30.0and the peer cycle makes two such calls, so a healthy first cycle has ~3.4 s of headroom.That reframes #4173: not a resource exhausting at exactly cycle 7, but an operation marginal from cycle 1 that eventually loses a race it was always close to.
Change
Stop on completeness rather than silence:
Content-Length, stop at the blank lineIt also separates headers from body.
response[256]previously held both, so a response with long headers could push the asserted fragment out of the window entirely — a failure mode independent of timing, and a plausible source of flaky content checks.Measurements (RP2350W ↔ ESP32-C6 SoftAP)
runNetClientTestValidation gap — the reason this is not "ready"
I have not established the baseline pass rate. My only pre-change data point is a single
ok=Truecycle, which says nothing about how the unmodified build scores over nine. So I cannot currently tell whether 6/9 is:The comparison run was cut short by host memory pressure mid-deploy, and the board's flashed build became indeterminate, so I stopped rather than report a number I could not stand behind. Note the harness itself fails at cycle 7, so the baseline may well be flaky too.
What would settle it: flash unmodified
master, run the same 9-cycle probe, compare pass rates. If baseline is also ~6/9, this is a clean win.For context, an earlier attempt of mine — stopping on 150 ms peer idle — was 2.8× faster with
ok=Falseon 7 of 8 cycles. I reverted it. That is why correctness, not speed, is the bar here.Verification done
bash lint— cleanrp2350wbuilds; RPC smoke PASS on hardware🤖 Generated with Claude Code
https://claude.ai/code/session_01KkufoNxfnNRU9psT3R9F51