[codex] Improve high-event hot paths#1389
Draft
helto4real wants to merge 3 commits into
Draft
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1389 +/- ##
====================================
Coverage 82% 82%
====================================
Files 202 202
Lines 3941 3959 +18
Branches 444 451 +7
====================================
+ Hits 3240 3257 +17
- Misses 531 533 +2
+ Partials 170 169 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Breaking change
None. This keeps public APIs unchanged and preserves raw
OnHassMessagepublication behavior.Proposed change
This PR implements the measured high-event performance improvements from the performance review plan.
The command/result hot path now uses an ID-indexed pending-result table instead of creating one filtered Rx subscription per command.
HomeAssistantConnectionregisters aTaskCompletionSource<HassMessage>for each command id, completes matchingresultmessages directly in the receive loop, and still publishes every rawHassMessagetoOnHassMessagefor ping, trigger, and diagnostic consumers.The websocket receive path now reads a complete websocket message into a byte buffer, detects whether the payload is a JSON object or coalesced array, and deserializes directly to
TorT[]. This removes the priorJsonElementintermediate and second typed deserialization on the ingest path while preserving chunked message and remote-close behavior.The state-change benchmark harness now keeps the owning
JsonDocumentalive for the benchmark lifetime, fixing the previous invalidJsonElementbaseline failure. The performance review document now includes the post-change results and report locations.Performance report summary, comparing the local baseline commit
d1eb2dd4 Add high-event performance benchmark baselinewith the post-change full BenchmarkDotNet run:NABenchmark artifacts from the post-change run are local ignored build outputs under:
benchmarks/NetDaemon.PerformanceBenchmarks/bin/Release/net10.0/BenchmarkDotNet.Artifacts/results/NetDaemon.PerformanceBenchmarks.Benchmarks.ResultDispatchBenchmarks-report-github.mdbenchmarks/NetDaemon.PerformanceBenchmarks/bin/Release/net10.0/BenchmarkDotNet.Artifacts/results/NetDaemon.PerformanceBenchmarks.Benchmarks.WebSocketPipelineBenchmarks-report-github.mdbenchmarks/NetDaemon.PerformanceBenchmarks/bin/Release/net10.0/BenchmarkDotNet.Artifacts/results/NetDaemon.PerformanceBenchmarks.Benchmarks.StateChangeJsonBenchmarks-report-github.mdbenchmarks/NetDaemon.PerformanceBenchmarks/bin/Release/net10.0/BenchmarkDotNet.Artifacts/results/NetDaemon.PerformanceBenchmarks.Benchmarks.QueuedObservableBenchmarks-report-github.mdThe websocket coalesced-events path trades higher allocation for substantially lower latency in this benchmark. That is called out in the report so future receive-path tuning can target both.
Type of change
Additional information
Detailed local report:
docs/performance/high-event-review.md.Checklist
If user exposed functionality or configuration are added/changed:
No user-facing functionality or configuration was added or changed.