-
Notifications
You must be signed in to change notification settings - Fork 990
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
chore: ScheduleInternal refactoring #3794
Conversation
A small refactoring to improve the flow of ScheduleInternal() as well as to prepare it for the next change that will reduce the CPU load from the shard queue. Signed-off-by: Roman Gershman <[email protected]>
run_barrier_.Start(unique_shard_cnt_); | ||
|
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.
there are no functional changes in this code
} | ||
|
||
if (schedule_fails.load(memory_order_relaxed) == 0) { |
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.
if we go into CanRunInlined branch then schedule_fails is 0. In fact schedule_fails check is only relevant for the else branch (IterateActiveShards)
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.
True, good simplification
@@ -762,6 +775,9 @@ void Transaction::ScheduleInternal() { | |||
}); | |||
} | |||
} | |||
|
|||
coordinator_state_ |= COORD_SCHED; |
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.
final phase: we succeeded scheduling - update the stats
} | ||
|
||
if (schedule_fails.load(memory_order_relaxed) == 0) { |
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.
True, good simplification
ScheduleContext schedule_ctx{this, can_run_immediately}; | ||
|
||
auto cb = [&schedule_ctx]() { | ||
if (!schedule_ctx.trans->ScheduleInShard(EngineShard::tlocal(), | ||
schedule_ctx.optimistic_execution)) { | ||
schedule_ctx.fail_cnt.fetch_add(1, memory_order_relaxed); | ||
} | ||
schedule_ctx.trans->FinishHop(); | ||
}; |
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.
- You forgot a rename in the last pr: can_run_immediately 🙂
- What's the raison d'être of ScheduleContext? 🤓 You don't pass it around, so it's not code simplicifaction. Is it to reduce the functor size by capturing a single pointer?
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.
- Will do.
- You will see it in the next PR (if it works)
A small refactoring to improve the flow of ScheduleInternal() as well as to prepare it for the next change that will reduce the CPU load from the shard queue.