docs(device): document and characterize per-connection thread accounting - #565
Conversation
…ing (#491) Items 1 and 2 of #491 (producer poll wakeups, per-device port enumeration) shipped in #514. Item 3 (a thread per SCPI exchange) was triaged and found to cost tens of microseconds against a 500ms+ exchange budget — not worth the memory-leak risk a park-instead-of-exit rework would introduce, and it overlaps the read-loop redesign #485 needs. What's left of the success criteria is the documentation: record the steady-state thread count and pin the per-exchange churn down with characterization tests so it doesn't drift unnoticed. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
PR Summary by QodoDocument and test DAQiFi per-connection thread accounting (#491)
AI Description
Diagram
High-Level Assessment
Files changed (2)
|
Code Review by Qodo
1.
|
… tests Compare Thread instances instead of ManagedThreadId — the old consumer thread has already exited by restart time, so its id is legally reusable and an id comparison could pass or fail for the wrong reason. Track every thread that entered the mock stream's Read so the "back to two threads" test actually proves the transient text-consumer thread exited rather than just that the known two are alive. Drop the sync-over-async .Wait() in the mock transport's Connect/Disconnect in favor of direct synchronous state flips. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
/agentic_review |
|
Code review by qodo was updated up to the latest commit 78589aa |
The comment claimed the "back to two threads" test tracks the producer thread via the stream's Read; the producer only writes, so ObservedReaderThreads only ever sees consumer-side readers. Fixed the wording so it describes what the assertion actually covers. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
/agentic_review |
|
Code review by qodo was updated up to the latest commit 23d6f86 |
|
Second agentic_review pass is clean: Bugs (0), Rule violations (0), Skill insights (0), and all three prior findings (flaky thread-id comparison, unproven "exactly two threads" claim, misleading comment) are marked resolved. CI is green. PR is ready for review. |
Summary
<remarks>toDaqifiDevice's class doc summarizing the thread accounting and linking back to perf(device): idle connected devices burn CPU — producer poll wakeups, per-device port enumeration every second, a new OS thread per SCPI exchange #491/perf(device): every SCPI text exchange pays ~700 ms of fixed polling/teardown overhead — make it event-driven #485.DaqifiDeviceThreadAccountingTests: idle-connected devices hold exactly 2 running threads; a text exchange restarts the protobuf consumer on a fresh thread; the device settles back to 2 running threads afterward.Test plan
dotnet builddotnet test src/Daqifi.Core.Tests/Daqifi.Core.Tests.csproj— full suite green (net9.0 + net10.0)DaqifiDeviceThreadAccountingTestspass individually🤖 Generated with Claude Code