project-chip / connectedhomeip

Matter (formerly Project CHIP) creates more connections between more objects, simplifying development for manufacturers and increasing compatibility for consumers, guided by the Connectivity Standards Alliance.
https://buildwithmatter.com
Apache License 2.0
7.34k stars 1.97k forks source link

Report generation logic in the Engine isn't very fair #13809

Open mrjerryjohns opened 2 years ago

mrjerryjohns commented 2 years ago

Problem

The current logic in the Engine keeps an index into the active handler list and increments that index across the set of reportable handlers present and services them.

This approach starts servicing handlers at arbitrary indices without accounting for the order in which handlers got dirty and became serviceable. This can result in highly jittered servicing times for subscriptions, especially if there are lots of subscribers OR if the time taken to service a subscriber is long (e.g subscriber is sleepy).

Solution

Insert into a queue handlers as they become reportable, and iterate through the queue to service them.

bzbarsky-apple commented 2 years ago

This needs to be fixed for 1.0. This can actually completely prevent some reads (not even subscriptions) being serviced, leading them to time out.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.