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

Use priority queue instead of queue #167

Merged
merged 8 commits into from
Aug 28, 2018
Merged

Use priority queue instead of queue #167

merged 8 commits into from
Aug 28, 2018

Conversation

erwinvaneyk
Copy link
Member

@erwinvaneyk erwinvaneyk commented Jul 13, 2018

The old implementation of the evaluation queue used a plain notification queue in the form of a gochannel. For each invocation there would be routinely evaluation 'tasks' added to this queue. In case of a large number of invocations, the incoming number of evaluation tasks could exceed the controller's capacity to consume these tasks, causing the queue to congest and tasks to be dropped. Especially since evaluation tasks were added for invocations that were not active (awaiting dynamic invocations to be completed for example), it could happen that evaluations that were known to result in no action would be added, while evaluations of fully active invocations would be dropped. This eventually would slow down the execution of invocations due to the clutter.

To fix this, I converted the queue into a priority queue. This priority queue has a number of constraints:
(1) every task in there is unique, so pushing a invocation evaluation multiple times in the queue will now result into only one being present; (2) the priority is based on two parameters: first, if an event has taken place for the invocation, and otherwise the time since last evaluation. So unless an event has updated the state of the invocation, each workflow invocation gets equal attention from the controller.

@erwinvaneyk erwinvaneyk changed the title Use priority queue instead of queue + fix parallelization of tasks Use priority queue instead of queue Jul 17, 2018
@erwinvaneyk erwinvaneyk added this to the 0.6.0 milestone Jul 19, 2018
@erwinvaneyk erwinvaneyk force-pushed the eval-heap branch 3 times, most recently from 7a9918c to e31a466 Compare July 27, 2018 11:14
@erwinvaneyk erwinvaneyk removed the wip label Jul 27, 2018
erwinvaneyk and others added 8 commits August 28, 2018 16:04
- The original implementation was too prone to bugs, and too complicated
to use
The resolving timeout (that kills a expression if it takes longer than 100ms) could get stuck on a non-responsive channel. This is likely when the 'vm' was garbage collected before the interrupt occured
This introduce a workqueue structure from k8s client, which support
thread safety object adding and polling reading.
@erwinvaneyk erwinvaneyk merged commit 397fea2 into master Aug 28, 2018
@erwinvaneyk erwinvaneyk deleted the eval-heap branch August 28, 2018 16:55
@ghost ghost mentioned this pull request Sep 15, 2018
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