Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize poller counting #6651

Merged
merged 1 commit into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions service/matching/poller/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type (
History interface {
UpdatePollerInfo(id Identity, info Info)
HasPollerAfter(earliestAccessTime time.Time) bool
GetPollerCount() int
GetPollerInfo(earliestAccessTime time.Time) []*types.PollerInfo
GetPollerIsolationGroups(earliestAccessTime time.Time) map[string]int
}
Expand Down Expand Up @@ -106,6 +107,10 @@ func (pollers *history) HasPollerAfter(earliestAccessTime time.Time) bool {
return false
}

func (pollers *history) GetPollerCount() int {
return pollers.historyCache.Size()
}

func (pollers *history) GetPollerInfo(earliestAccessTime time.Time) []*types.PollerInfo {
var result []*types.PollerInfo
// optimistic size get, it can change before Iterator call.
Expand Down
10 changes: 10 additions & 0 deletions service/matching/poller/history_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,16 @@ func TestHistory_HasPollerAfter(t *testing.T) {
})
}

func TestGetPollerCount(t *testing.T) {
mockCtrl := gomock.NewController(t)
mockCache := cache.NewMockCache(mockCtrl)
mockCache.EXPECT().Size().Return(10)
p := &history{
historyCache: mockCache,
}
assert.Equal(t, 10, p.GetPollerCount())
}

func TestGetPollerInfo(t *testing.T) {
t.Run("with_time_filter", func(t *testing.T) {
mockCtrl := gomock.NewController(t)
Expand Down
12 changes: 2 additions & 10 deletions service/matching/tasklist/task_list_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func NewManager(

tlMgr.pollerHistory = poller.NewPollerHistory(func() {
scope.UpdateGauge(metrics.PollerPerTaskListCounter,
float64(len(tlMgr.pollerHistory.GetPollerInfo(time.Time{}))))
float64(tlMgr.pollerHistory.GetPollerCount()))
}, timeSource)

livenessInterval := taskListConfig.IdleTasklistCheckInterval()
Expand Down Expand Up @@ -945,15 +945,7 @@ func (c *taskListManagerImpl) emitMisconfiguredPartitionMetrics() {
if c.config.NumReadPartitions() != c.config.NumWritePartitions() {
c.scope.UpdateGauge(metrics.TaskListReadWritePartitionMismatchGauge, 1)
}
pollerCount := len(c.pollerHistory.GetPollerInfo(time.Time{}))
if c.enableIsolation { // if isolation enabled, get the minimum poller count among the isolation groups
pollerCountsByIsolationGroup := c.pollerHistory.GetPollerIsolationGroups(time.Time{})
for _, count := range pollerCountsByIsolationGroup {
if count < pollerCount {
pollerCount = count
}
}
}
Comment on lines -948 to -956
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are isolation related logic. Are they still needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the tasklist partition <-> isolation group mapping that I'm currently implementing it's no longer accurate. We've disabled isolation broadly so it's not an issue in the mean time.

pollerCount := c.pollerHistory.GetPollerCount()
if pollerCount < c.config.NumReadPartitions() || pollerCount < c.config.NumWritePartitions() {
c.scope.Tagged(metrics.IsolationEnabledTag(c.enableIsolation)).UpdateGauge(metrics.TaskListPollerPartitionMismatchGauge, 1)
}
Expand Down