Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Refactor poller tracking from tasklist to poller package #6777

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

Merged
merged 1 commit into from
Apr 3, 2025

Conversation

natemort
Copy link
Member

@natemort natemort commented Apr 1, 2025

Address a longstanding TODO, moving outstanding poller tracking to the poller package. This simplifies task_list_manager and consolidates outstanding poller tracking with the poller history.

Improve the calculation of whether there are recent pollers for a given isolation group. Currently we calculate the number of pollers for every isolation group and then check whether the value for a given isolation group is greater than zero. This requires iterating through the entire recent pollers cache. Given it has a maximum size of 5000, this isn't a great thing to do for every single task we dispatch. Instead we can store the number of outstanding pollers by group and the last time a poll for the group ended, making it a consistently quick check.

Additionally optimize HasAnyAfter to use a similar mechanism, although the frequency at which that is used makes that less important.

Fix the double counting of getRecentPollersByIsolationGroup by tracking in the poller history whether a poller is outstanding. Currently we iterate through the poller history then through the outstanding pollers, but if a poller began its poll within the TaskIsolationPollerWindow it gets counted twice. The accuracy of this function isn't particularly important, but we should err on the side of correctness.

What changed?

  • Refactor poller tracking from task_list_manager to new poller.Manager
  • Optimize checking whether an isolation group has recent pollers
  • Fix double counting of recent pollers for isolation groups

Why?

  • General cleanup
  • Minor correctness issue of counting pollers per isolation group
  • Ensure that we're not iterating over all pollers every time we dispatch a task

How did you test it?

  • Unit/integration tests

Potential risks

  • If this fails then canceling outstanding pollers or tracking whether a sticky tasklist has pollers could break.

Release notes

Documentation Changes

StartPoll(pollerID string, cancelFunc context.CancelFunc, info *Info)
EndPoll(pollerID string)
CancelPoll(pollerID string) bool
HasGroupAfter(isolationGroup string, earliest time.Time) bool
Copy link
Member

Choose a reason for hiding this comment

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

HasPollerFromIsolationGroupAfter is a better name

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

EndPoll(pollerID string)
CancelPoll(pollerID string) bool
HasGroupAfter(isolationGroup string, earliest time.Time) bool
HasAnyAfter(after time.Time) bool
Copy link
Member

Choose a reason for hiding this comment

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

HasPollerAfter is a better name, I think

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

Address a longstanding TODO, moving outstanding poller tracking to the poller package. This simplifies task_list_manager and consolidates outstanding poller tracking with the poller history.

Improve the calculation of whether there are recent pollers for a given isolation group. Currently we calculate the number of pollers for every isolation group and then check whether the value for a given isolation group is greater than zero. This requires iterating through the entire recent pollers cache. Given it has a maximum size of 5000, this isn't a great thing to do for every single task we dispatch. Instead we can store the number of outstanding pollers by group and the last time a poll for the group ended, making it a consistently quick check.

Additionally optimize HasAnyAfter to use a similar mechanism, although the frequency at which that is used makes that less important.

Fix the double counting of getRecentPollersByIsolationGroup by tracking in the poller history whether a poller is outstanding. Currently we iterate through the poller history then through the outstanding pollers, but if a poller began its poll within the TaskIsolationPollerWindow it gets counted twice. The accuracy of this function isn't particularly important, but we should err on the side of correctness.
@natemort natemort merged commit 9074b05 into cadence-workflow:master Apr 3, 2025
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.