-
Notifications
You must be signed in to change notification settings - Fork 107
chore(concurrency): sleep if there are no tasks #1991
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1991 +/- ##
=======================================
Coverage 78.45% 78.45%
=======================================
Files 62 62
Lines 8970 8970
Branches 8970 8970
=======================================
Hits 7037 7037
Misses 1486 1486
Partials 447 447 ☔ View full report in Codecov by Sentry. |
I don't like using I propose adding |
I renamed the method but forgot to rename the corresponding test. Suggestion: fn test_finish_abort( |
Suggestion: let scheduler =
default_scheduler!(chunk_size: DEFAULT_CHUNK_SIZE, execution_index: execution_index);
scheduler.set_tx_status(tx_index, TransactionStatus::Executed);
let mut result = None;
result = scheduler.finish_abort(tx_index);
let new_status = scheduler.lock_tx_status(tx_index);
if execution_index > tx_index {
assert_eq!(result, Some(Task::ExecutionTask(tx_index)));
assert_eq!(*new_status, TransactionStatus::Executing);
} else {
assert!(result.is_none());
assert_eq!(*new_status, TransactionStatus::ReadyToExecute);
} |
Oops, the status should be |
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.
Reviewable status: 0 of 4 files reviewed, 4 unresolved discussions (waiting on @noaov1 and @Yoni-Starkware)
crates/blockifier/src/concurrency/scheduler_test.rs
line 216 at r1 (raw file):
#[rstest] #[case::not_aborted(0, 10, false)]
We no longer have the not aborted flow inside this method (if it's not aborted we simply don't call the method).
Here's a PR that fixes this test, in case you don't want all these changes in your PR:
#1993
crates/blockifier/src/concurrency/scheduler_test.rs
line 219 at r1 (raw file):
Previously, avi-starkware wrote…
I renamed the method but forgot to rename the corresponding test.
Here's a PR that fixes this test, in case you don't want all these changes in your PR:
#1993
crates/blockifier/src/concurrency/scheduler_test.rs
line 222 at r1 (raw file):
#[case] tx_index: TxIndex, #[case] execution_index: TxIndex, #[case] aborted: bool,
We no longer have the not aborted flow inside this method (if it's not aborted we simply don't call the method).
Here's a PR that fixes this test, in case you don't want all these changes in your PR:
#1993
crates/blockifier/src/concurrency/scheduler_test.rs
line 247 at r1 (raw file):
Previously, avi-starkware wrote…
Oops, the status should be
TransactionStatus::Aborting
.
Here's a PR that fixes this test, in case you don't want all these changes in your PR:
#1993
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.
None means that you're not holding any task and you need to query the scheduler.
NoTask means that there are no pending tasks at all (and you can go to sleep).
I needed to distinguish between these cases because I didn't want to sleep, for example, after every execute.
Not sure I like Wait, it's too specific - it describes what you do if there are no tasks. I can do nothing or call spin_loop for example
But I agree it's not ideal.I'll think
Reviewable status: 0 of 4 files reviewed, 4 unresolved discussions (waiting on @noaov1)
61c06f7
to
40170b8
Compare
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.
Reviewable status: 0 of 4 files reviewed, 4 unresolved discussions (waiting on @avi-starkware and @noaov1)
crates/blockifier/src/concurrency/scheduler_test.rs
line 216 at r1 (raw file):
Previously, avi-starkware wrote…
We no longer have the not aborted flow inside this method (if it's not aborted we simply don't call the method).
Here's a PR that fixes this test, in case you don't want all these changes in your PR:
#1993
Done.
crates/blockifier/src/concurrency/scheduler_test.rs
line 219 at r1 (raw file):
Previously, avi-starkware wrote…
Here's a PR that fixes this test, in case you don't want all these changes in your PR:
#1993
Done.
crates/blockifier/src/concurrency/scheduler_test.rs
line 222 at r1 (raw file):
Previously, avi-starkware wrote…
We no longer have the not aborted flow inside this method (if it's not aborted we simply don't call the method).
Here's a PR that fixes this test, in case you don't want all these changes in your PR:
#1993
Done.
crates/blockifier/src/concurrency/scheduler_test.rs
line 247 at r1 (raw file):
Previously, avi-starkware wrote…
Here's a PR that fixes this test, in case you don't want all these changes in your PR:
#1993
Done.
40170b8
to
8a182b9
Compare
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.
@avi-starkware I changed it a bit, WDYT?
Reviewable status: 0 of 4 files reviewed, all discussions resolved (waiting on @noaov1)
I understood your usage of |
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.
finish_abort
can only return a re-execution task, so using option there is not so bad IMO
I can also change validate
to return a boolean, something like this
if let Some(re_execute_task) = self.validate(tx_index) {
task = re_execute_task;
continue;
}
==>>
let should_re_execute = self.validate(tx_index) {
if should_re_execute {
task = Task::ExecuteTask(tx_index);
continue;
}
Reviewable status: 0 of 4 files reviewed, all discussions resolved (waiting on @noaov1)
How about something like: Also, note that when we add dependencies, |
8a182b9
to
9fe44fa
Compare
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.
Good point, thanks.
Done (cc @noaov1)
Reviewable status: 0 of 4 files reviewed, all discussions resolved (waiting on @noaov1)
240a886
to
f52883d
Compare
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.
Reviewed 3 of 4 files at r4, 1 of 1 files at r5, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @noaov1)
This case will usually mean that the status of the transaction wasn't right for Execution/Validation. Suggestion: Task::AskForTask |
Suggestion: Task::AskForTask |
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.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @avi-starkware and @noaov1)
crates/blockifier/src/concurrency/scheduler.rs
line 105 at r5 (raw file):
Previously, avi-starkware wrote…
This case will usually mean that the status of the transaction wasn't right for Execution/Validation.
This means that there is no task available, and we should wait, right?
Previously, Yoni-Starkware (Yoni) wrote…
When we reach this line, it is usually because the transaction's status at the |
f52883d
to
db34c50
Compare
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.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @avi-starkware and @noaov1)
crates/blockifier/src/concurrency/scheduler.rs
line 105 at r5 (raw file):
Previously, avi-starkware wrote…
When we reach this line, it is usually because the transaction's status at the
execution_index
is notReadyToExecute
.
Done.
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.
Reviewable status: 0 of 5 files reviewed, 3 unresolved discussions (waiting on @avi-starkware and @noaov1)
crates/blockifier/src/concurrency/scheduler.rs
line 95 at r6 (raw file):
let index_to_execute = self.execution_index.load(Ordering::Acquire); if min(index_to_validate, index_to_execute) >= self.chunk_size {
@barak-b-starkware FYI: I restored this check in order to know when to stop the busy loop
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.
Reviewed 5 of 5 files at r6, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @noaov1)
Co-authored-by: glihm <glihm@users.noreply.github.com>
This change is