-
Notifications
You must be signed in to change notification settings - Fork 13
gang: track incomplete_tasks on-demand via bind/unbind hooks #507
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -154,6 +154,7 @@ impl Plugin for GangPlugin { | |||||||
| fn on_session_bind(&mut self, ssn: SessionInfoPtr) { | ||||||||
| if let Some(state) = self.ssn_state.get_mut(&ssn.id) { | ||||||||
| state.bound += 1; | ||||||||
| state.incomplete_tasks = state.incomplete_tasks.saturating_sub(1); | ||||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
|
|
@@ -166,6 +167,7 @@ impl Plugin for GangPlugin { | |||||||
| fn on_session_unbind(&mut self, ssn: SessionInfoPtr) { | ||||||||
| if let Some(state) = self.ssn_state.get_mut(&ssn.id) { | ||||||||
| state.bound = state.bound.saturating_sub(1); | ||||||||
| state.incomplete_tasks = state.incomplete_tasks.saturating_add(1); | ||||||||
|
Comment on lines
169
to
+170
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Double-Counting & Premature Fulfillment BugIncrementing
Suggested change
|
||||||||
| } | ||||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double-Counting & Premature Fulfillment Bug
Decrementing
incomplete_taskshere introduces a critical logic bug:RunningorBindingstate, notSucceed/Failed/Cancelled). Therefore, binding a task does not reduce the number of incomplete tasks.total >= needed, wheretotal = allocated + boundandneeded = div_ceil(incomplete_tasks, batch_size) * batch_size. If you decrementincomplete_tasks(reducingneeded) and incrementbound(increasingtotal) simultaneously, you double-count the progress.For example, with
batch_size = 2and4pending tasks:needed = 4,total = 0.needed = 4,total = 1.needed = 2,total = 2->is_fulfilledbecomestrueprematurely, leaving the remaining 2 tasks without executors.Revert this change to keep
incomplete_tasksstatic during the scheduling cycle.