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

chore: ScheduleInternal refactoring #3794

Merged
merged 1 commit into from
Sep 26, 2024
Merged

chore: ScheduleInternal refactoring #3794

merged 1 commit into from
Sep 26, 2024

Conversation

romange
Copy link
Collaborator

@romange romange commented Sep 25, 2024

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.

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]>
@romange romange requested review from dranikpg and chakaz September 25, 2024 14:29
run_barrier_.Start(unique_shard_cnt_);

Copy link
Collaborator Author

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) {
Copy link
Collaborator Author

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)

Copy link
Contributor

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;
Copy link
Collaborator Author

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) {
Copy link
Contributor

Choose a reason for hiding this comment

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

True, good simplification

Comment on lines +727 to +735
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();
};
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. You forgot a rename in the last pr: can_run_immediately 🙂
  2. 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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

  1. Will do.
  2. You will see it in the next PR (if it works)

@romange romange merged commit 70ad113 into main Sep 26, 2024
12 checks passed
@romange romange deleted the Pr1 branch September 26, 2024 05:14
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