Skip to content

Commit

Permalink
optimize the buffer pressure event delievery (#18405)
Browse files Browse the repository at this point in the history
* optimize the buffer pressure event delievery

Summary of Changes:

If no event path have been allocated in pool, even though the current event buffer is full, there is no need to trigger event delivery run.

* add comment
  • Loading branch information
yunhanw-google authored and pull[bot] committed Nov 29, 2023
1 parent 4afb8db commit bd3633f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/app/reporting/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,15 @@ CHIP_ERROR Engine::ScheduleBufferPressureEventDelivery(uint32_t aBytesWritten)

CHIP_ERROR Engine::ScheduleEventDelivery(ConcreteEventPath & aPath, uint32_t aBytesWritten)
{
// If we literally have no read handlers right now that care about any events,
// we don't need to call schedule run for event.
// If schedule run is called, actually we would not delivery events as well.
// Just wanna save one schedule run here
if (InteractionModelEngine::GetInstance()->mEventPathPool.Allocated() == 0)
{
return CHIP_NO_ERROR;
}

bool isUrgentEvent = false;
InteractionModelEngine::GetInstance()->mReadHandlers.ForEachActiveObject([&aPath, &isUrgentEvent](ReadHandler * handler) {
if (handler->IsType(ReadHandler::InteractionType::Read))
Expand Down

0 comments on commit bd3633f

Please sign in to comment.