-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
[BlockSTM] Lazy (potentially iterable) txns input to BlockSTM #14568
Conversation
⏱️ 1h 40m total CI duration on this PR
|
f8ed8c1
to
8ba7e89
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
8ba7e89
to
ba24673
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
match *status { | ||
BlockingTransactionStatus::Ready(ref txn) => txn.clone(), | ||
BlockingTransactionStatus::Waiting => { | ||
status = txn.cvar.wait(status).unwrap(); |
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.
from the documentation of condvar wait:
Note that this function is susceptible to spurious wakeups. Condition variables normally have a boolean predicate associated with them, and the predicate must always be checked each time this function returns to protect against spurious wakeups.
This can lead to panic on Line 70 below. A typical pattern is to do it in a loop, we have an example here:
let (lock, cvar) = &*dep_condition; |
DependencyCondvar defined here:
type DependencyCondvar = Arc<(Mutex<DependencyStatus>, Condvar)>; |
I think what we can do here is have separate condvar with a status lock, use in a loop, and separately the (option of) transaction (or ExplicitSyncWrapper of Option if it needs sync bounds), so we can have an interface for naked &.
An Arc isn't really a big issue but in general I want us to try to reduce reliance on them in cases they aren't actually needed (lifetime guaranteed and reference counting not needed), and this seems like a good example of such a case.
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.
@ziaptos: minor question here out of curiosity, if it's not too easy to change to non-arc, would it be better to return &Arc? (or triopmhe arc?)
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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.
LGTM
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
01d817c
to
22df6f2
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Currently BlockSTM takes in a block (vec) of txns and executes them. This commits adds a capability where we don't need to provide all the txns in the block upfront, rather provide them as per any desired logic in the system. The commit has a default implementation 'DefaultTxnProvider' where all txns are provided upfront as per current logic, and also a reference implementation of 'BlockingTxnsProvider' where txns can be provided after BlockSTM starts execution. Note: One should be careful while using 'BlockingTxnsProvider' because if BlockSTM chooses to execute a txn that is not yet provided, then that thread gets blocked until such a txn is provided. This could lead to performance degradation.
22df6f2
to
2815641
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ Forge suite
|
✅ Forge suite
|
✅ Forge suite
|
* [BlockSTM] Iterable txns input to BlockSTM Currently BlockSTM takes in a block (vec) of txns and executes them. This commits adds a capability where we don't need to provide all the txns in the block upfront, rather provide them as per any desired logic in the system. The commit has a default implementation 'DefaultTxnProvider' where all txns are provided upfront as per current logic, and also a reference implementation of 'BlockingTxnsProvider' where txns can be provided after BlockSTM starts execution. This is done by rust's OnceCell<>. Note: One should be careful while using 'BlockingTxnsProvider' because if BlockSTM chooses to execute a txn that is not yet provided, then that thread gets blocked until such a txn is provided. This could lead to performance degradation. * Address issues that can arise from spurious wakeups in Condvar * In BlockingTransaction use OnceCell<> instead of Mutex and Cvar * Keep BlockingTransaction internal to BlockingTxnProvider * Remove BlockingTransaction struct; instead use OnceCell directly
Currently BlockSTM takes in a block (vec) of txns and executes them.
This commits adds a capability where we don't need to provide all the
txns in the block upfront, rather provide them as per any desired logic
in the system.
The commit has a default implementation 'DefaultTxnProvider' where all
txns are provided upfront as per current logic, and also a reference
implementation of 'BlockingTxnsProvider' where txns can be provided
after BlockSTM starts execution.
Note: One should be careful while using 'BlockingTxnsProvider' because
if BlockSTM chooses to execute a txn that is not yet provided, then that
thread gets blocked until such a txn is provided. This could lead to
performance degradation.
Description
Type of Change
Which Components or Systems Does This Change Impact?
How Has This Been Tested?
Key Areas to Review
Checklist