diff --git a/src/analytics/collector.cc b/src/analytics/collector.cc index 72f9a24b0d8..0124296f80e 100644 --- a/src/analytics/collector.cc +++ b/src/analytics/collector.cc @@ -480,6 +480,7 @@ void Collector::GetGeneratorSummaryInfo(vector *genlist) { gsinfo.set_db_drop_level(db_drop_level); } } + gsinfo.set_max_sm_queue_count(gen->GetSandeshStateMachineMaxQueueCount()); genlist->push_back(gsinfo); } } diff --git a/src/analytics/collector_uve.sandesh b/src/analytics/collector_uve.sandesh index e5db52dc164..d97b96e91b0 100644 --- a/src/analytics/collector_uve.sandesh +++ b/src/analytics/collector_uve.sandesh @@ -112,6 +112,7 @@ struct GeneratorSummaryInfo { 7: optional u64 db_queue_count 8: optional string db_drop_level 9: optional bool sm_back_pressure + 10: optional u64 max_sm_queue_count } /** diff --git a/src/analytics/generator.h b/src/analytics/generator.h index 773cf6d5851..e82a7f506cb 100644 --- a/src/analytics/generator.h +++ b/src/analytics/generator.h @@ -91,6 +91,9 @@ class SandeshGenerator : public Generator { void StartDbifReinit(); virtual DbHandler * GetDbHandler() const { return db_handler_.get(); } bool UseGlobalDbHandler() const { return use_global_dbhandler_; } + uint32_t GetSandeshStateMachineMaxQueueCount() const { + return state_machine_->GetMaxQueueCount(); + } private: virtual bool ProcessRules(const VizMsg *vmsg, bool rsc); diff --git a/src/base/queue_task.h b/src/base/queue_task.h index c696b57fdc1..a06e975b58e 100644 --- a/src/base/queue_task.h +++ b/src/base/queue_task.h @@ -587,6 +587,7 @@ class WorkQueue { } AtomicDecrementQueueCount(&entry); drops_++; + max_queue_len_ = count_; return false; } diff --git a/src/base/test/queue_task_test.cc b/src/base/test/queue_task_test.cc index 6c25bd5d084..4c270e9b213 100644 --- a/src/base/test/queue_task_test.cc +++ b/src/base/test/queue_task_test.cc @@ -208,7 +208,7 @@ class QueueTaskTest : public ::testing::Test { tbb::atomic shutdown_test_exit_callback_sleep_; }; -TEST_F(QueueTaskTest, StartRunnerBasic) { +TEST_F(QueueTaskTest, StartRunnerBasic) TaskScheduler *scheduler = TaskScheduler::GetInstance(); // Always do start runner work_queue_.SetStartRunnerFunc( @@ -244,6 +244,24 @@ TEST_F(QueueTaskTest, StartRunnerBasic) { EXPECT_EQ(2, work_queue_.NumEnqueues()); EXPECT_EQ(1, work_queue_.NumDequeues()); EXPECT_EQ(1, work_queue_.Length()); + // Verify WorkQueue max_queue_len_ + EXPECT_EQ(1, work_queue_.max_queue_len()); + work_queue_.Enqueue(enqueue_counter++); + work_queue_.Enqueue(enqueue_counter++); + work_queue_.Enqueue(enqueue_counter++); + task_util::WaitForIdle(1); + EXPECT_EQ(3, work_queue_.max_queue_len()); + // Add test case for bounded workq + work_queue_.SetBounded(true); + work_queue_.size_(4); + work_queue_.Enqueue(enqueue_counter++); + work_queue_.Enqueue(enqueue_counter++); + work_queue_.Enqueue(enqueue_counter++); + work_queue_.Enqueue(enqueue_counter++); + EXPECT_EQ(4, work_queue_.max_queue_len()); + work_queue_.Enqueue(enqueue_counter++); + EXPECT_EQ(4, work_queue_.max_queue_len()); + task_util::WaitForIdle(1); } TEST_F(QueueTaskTest, StartRunnerInternals) {