Comments (10)
I like this approach, but we should be a bit careful with the locks on shared resources: cost_tracker, account_locks
- we weant to minimize the time we hold these locks
- we need to make sure we are always grabbing these locks in a "safe" order so that we cannot dead-lock (i.e. don't allow thread 1 to take cost_tracker then account_locks, but thread 2 takes account_locks then cost_tracker).
In pursuit of 1, any transaction cost calculation should be done outside of the locks - I'm fairly certain this is already the case.
And to be clear, I think we should also not grab/release locks per tx, and do it for the batch like we do now.
from solana.
It seems we also may want different solutions for old vs new scheduler.
Old scheduler has a high probability that locking will fail, but new scheduler have near-zero lock-failures.
So it'd make sense for new scheduler to just lock and then reserve in qos.
That could be problematic in the old scheduler where we succeed in locking, which prevents other threads from locking, then cannot reserve in qos.
If we're hitting block-limits this still seems better, because qos getting maxed-out on block-limits means all other threads are blocked.
So it seems in either case we want to have the order: (lock, qos reserve, unlock)
wdyt?
from solana.
I think this solution is better than what I proposed in #34807 and this issue can replace that one if we agree this is a better approach.
from solana.
agree this is better approach.
from solana.
2. we need to make sure we are always grabbing these locks in a "safe" order so that we cannot dead-lock (i.e. don't allow thread 1 to take cost_tracker then account_locks, but thread 2 takes account_locks then cost_tracker).
Even I don't think we take these two locks together today, I'm not so confident we can keep stable global order for them. Rather like to avoid taking multiple locks.
from solana.
Been back-n-forth on several tries, I found I largely agree with @apfitzge points above. To not to grab two locks at a time, and do it in batch instead of tx-by-tx. I'm leaning to original solution: reserve CU for batch -> acquire locks for batch -> remove CU for transactions failed get accounts lock, and do it in batch. (first two steps are as-is, just adding 3rd step immediately after locking). What are your opinions?
from solana.
Yeah taking both locks is probably too risky.. How about we first reserve as much as cost as we need in qos and then keep track of how much of that cost we've used so far as we do the transaction account locking loop? After locking, we release any reserved cost back to the qos cost tracker for other workers.
from solana.
Yeah taking both locks is probably too risky.. How about we first reserve as much as cost as we need in qos and then keep track of how much of that cost we've used so far as we do the transaction account locking loop? After locking, we release any reserved cost back to the qos cost tracker for other workers.
This still seems to suffer from the issue though, within the same thread.
Let's say we're close to our limits and we receive a batch [Tx1, Tx2].
Taking both costs would put us over the block-limits, but either can fit.
If Tx1 cannot take locks, then we should ideally still reserve & execute Tx2.
If we (reserve qos, take locks, free qos) then neither tx will get executed in this case.
from solana.
Yeah taking both locks is probably too risky.. How about we first reserve as much as cost as we need in qos and then keep track of how much of that cost we've used so far as we do the transaction account locking loop? After locking, we release any reserved cost back to the qos cost tracker for other workers.
This still seems to suffer from the issue though, within the same thread.
Let's say we're close to our limits and we receive a batch [Tx1, Tx2]. Taking both costs would put us over the block-limits, but either can fit. If Tx1 cannot take locks, then we should ideally still reserve & execute Tx2.
If we (reserve qos, take locks, free qos) then neither tx will get executed in this case.
Yea, it does not help on this particular batch, but released cost_tracker space helps other threads to book their txs.
from solana.
So it seems in either case we want to have the order: (lock, qos reserve, unlock)
Yea, I initially considered this (without thinking about new scheduler behavior). I felt better not to messing around accounts_lock too much, but that might not be a good argument anyway.
from solana.
Related Issues (20)
- Scheduler: Separate Receiving from Scheduling Thread HOT 2
- Avoid an unnecessary copy of AccountHash in the write-path of tiered-storage
- Allow a mixture of stake warmup/cooldown up to the 18% limit
- Gossip Votes Held Before BankingStage HOT 2
- Feature Gate: Removing unwanted rounding in fee calculation
- SDK: `Signer` and `Signers` traits are problematic
- error: package `solana-program v1.18.0` cannot be built because it requires rustc 1.72.0 or newer, while the currently active rustc version is 1.68.0-dev HOT 18
- Very first tutorial does not work. All new users will fail if they don't understand how to debug your codebase on an intimate level. HOT 17
- Stack error log on 1.18.0 release
- Feature Gate: notify state machine of duplicate proofs
- v1.18 hash mismatch HOT 5
- cargo test fails on M1 with 'Could not find `protoc` installation' HOT 3
- the trait bound `T: borsh::de::BorshDeserialize` is not satisfied HOT 2
- Need to change broadcast_duplicates_run to use merkle shreds
- Flaky Test: solana-streamer quic::test::test_quic_server_block_multiple_connections
- Improve AccoutsFile::appends_account() return value format
- Update Zeroize to new version? HOT 1
- Potential bug in inner_instructions HOT 3
- ERROR cargo_build_sbf] Failed to obtain package metadata: `cargo metadata` exited with an error: Updating registry `https://github.com/rust-lang/crates.io-index` HOT 1
- Liquidity pool creation HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from solana.