-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Limit the number of transactions in pending set #8777
Conversation
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, have tested this on my machine to confirm it fixes the slow RPC issue with very large --tx-queue-size
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.
Still not too familiar with the codebase, but LGTM overall. All comments are minor.
transaction-pool/src/tests/mod.rs
Outdated
let tx0 = txq.import(b.tx().nonce(0).gas_price(5).new()).unwrap(); | ||
let tx1 = txq.import(b.tx().nonce(1).gas_price(5).new()).unwrap(); | ||
let tx2 = txq.import(b.tx().nonce(2).new()).unwrap(); | ||
let tx3 =txq.import(b.tx().nonce(3).gas_price(4).new()).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.
nit: Space after =
.
// gap | ||
txq.import(b.tx().sender(1).nonce(5).new()).unwrap(); | ||
|
||
let tx9 = txq.import(b.tx().sender(2).nonce(0).new()).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.
It's a bit odd that this is tx9 (no gap in tx numbering), whereas there's a gap in numbering between tx3 and tx5.
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.
It's because tx3
and tx5
are coming from the same sender and tx9
is from a different one.
I guess tx1_1
would be a bit more appropriate to describe all the details. Can change it if you believe it makes things clearer.
ethcore/sync/src/api.rs
Outdated
@@ -373,7 +377,9 @@ struct SyncProtocolHandler { | |||
impl NetworkProtocolHandler for SyncProtocolHandler { | |||
fn initialize(&self, io: &NetworkContext) { | |||
if io.subprotocol_name() != WARP_SYNC_PROTOCOL_ID { | |||
io.register_timer(0, Duration::from_secs(1)).expect("Error registering sync timer"); | |||
io.register_timer(PEERS_TIMER, Duration::from_millis(700)).expect("Error registering sync timer"); |
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.
s/sync/peers/ in the expect message
ethcore/sync/src/api.rs
Outdated
io.register_timer(0, Duration::from_secs(1)).expect("Error registering sync timer"); | ||
io.register_timer(PEERS_TIMER, Duration::from_millis(700)).expect("Error registering sync timer"); | ||
io.register_timer(SYNC_TIMER, Duration::from_millis(1100)).expect("Error registering sync timer"); | ||
io.register_timer(TX_TIMER, Duration::from_millis(1300)).expect("Error registering sync timer"); |
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.
The expect message should be changed probably.
miner/src/pool/queue.rs
Outdated
@@ -261,15 +280,27 @@ impl TransactionQueue { | |||
scoring::NonceAndGasPrice, | |||
Listener, | |||
>) -> T, | |||
{ | |||
debug!(target: "txqueue", "Re-computing pending set for block: {}", block_number); | |||
let _timer = ::trace_time::PerfTimer::new("pool::collect_pending"); |
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.
Any reason not to use the trace_time!
macro?
return pending; | ||
} | ||
|
||
let pending: Vec<_> = self.collect_pending(client, block_number, current_timestamp, nonce_cap, |i| i.collect()); | ||
// In case we don't have a cached set, but we don't care about order |
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.
Might be nice to test this case, and assert unordered results and that the cache is left alone.
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.
Test added.
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.
I'm not very familiar with the context, but LGTM
Does not compile.
|
Confirmed. And while the above is easy enough to fix ( Also needs a |
* Unordered iterator. * Use unordered and limited set if full not required. * Split timeout work into smaller timers. * Avoid collecting all pending transactions when mining * Remove println. * Use priority ordering in eth-filter. * Fix ethcore-miner tests and tx propagation. * Review grumbles addressed. * Add test for unordered not populating the cache. * Fix ethcore tests. * Fix light tests. * Fix ethcore-sync tests. * Fix RPC tests.
…rp_sync_on_light_client * 'master' of https://github.com/paritytech/parity: (29 commits) Block 0 is valid in queries (openethereum#8891) fixed osx permissions (openethereum#8901) Atomic create new files with permissions to owner in ethstore (openethereum#8896) Add ETC Cooperative-run load balanced parity node (openethereum#8892) Add support for --chain tobalaba (openethereum#8870) fix some warns on nightly (openethereum#8889) Add new ovh bootnodes and fix port for foundation bootnode 3.2 (openethereum#8886) SecretStore: service pack 1 (openethereum#8435) Handle removed logs in filter changes and add geth compatibility field (openethereum#8796) fixed ipc leak, closes openethereum#8774 (openethereum#8876) scripts: remove md5 checksums (openethereum#8884) hardware_wallet/Ledger `Sign messages` + some refactoring (openethereum#8868) Check whether we need resealing in miner and unwrap has_account in account_provider (openethereum#8853) docker: Fix alpine build (openethereum#8878) Remove mac os installers etc (openethereum#8875) README.md: update the list of dependencies (openethereum#8864) Fix concurrent access to signer queue (openethereum#8854) Tx permission contract improvement (openethereum#8400) Limit the number of transactions in pending set (openethereum#8777) Use sealing.enabled to emit eth_mining information (openethereum#8844) ...
* Unordered iterator. * Use unordered and limited set if full not required. * Split timeout work into smaller timers. * Avoid collecting all pending transactions when mining * Remove println. * Use priority ordering in eth-filter. * Fix ethcore-miner tests and tx propagation. * Review grumbles addressed. * Add test for unordered not populating the cache. * Fix ethcore tests. * Fix light tests. * Fix ethcore-sync tests. * Fix RPC tests.
* parity-version: stabelize 1.11 * parity-version: bump stable to 1.11.7 * Don't fetch snapshot chunks at random (#9088) * Offload cull to IoWorker. * Limit the number of transactions in pending set (#8777) * Unordered iterator. * Use unordered and limited set if full not required. * Split timeout work into smaller timers. * Avoid collecting all pending transactions when mining * Remove println. * Use priority ordering in eth-filter. * Fix ethcore-miner tests and tx propagation. * Review grumbles addressed. * Add test for unordered not populating the cache. * Fix ethcore tests. * Fix light tests. * Fix ethcore-sync tests. * Fix RPC tests. * Make sure to produce full blocks. * Update hidapi, fixes #7542 (#9108) * docker: add cmake dependency (#9111) * Fix miner tests. * Revert "Make sure to produce full blocks." This reverts commit b12d592. * Update light client hardcoded headers (#9098) * Insert Kovan hardcoded headers until #7690241 * Insert Kovan hardcoded headers until block 7690241 * Insert Ropsten hardcoded headers until #3612673 * Insert Mainnet hardcoded headers until block 5941249 * Make sure to produce full blocks. (#9115) * Insert ETC (classic) hardcoded headers until block #6170625 (#9121) * fix verification in ethcore-sync collect_blocks (#9135) * `evm bench` fix broken dependencies (#9134) * `evm bench` use valid dependencies Benchmarks of the `evm` used stale versions of a couple a crates that this commit fixes! * fix warnings
With large pools and in case the node is not
--force-sealing
the pending set was actually being computed in the sync thread (propagate transactions on timeout). That could cause a significant delay, since there was nothing in the cache and the pool was pretty huge, but for propagation we never needed more than 64 first transactions.max_len
argument to avoid constructing too large pending sets.UnorderedIterator
that can be computed faster than the priority one. This for now is only used forparity_allTransactions
RPC, but in future could be used in places where we don't really care that much about strict ordering (RPC filters maybe)CC @folsen
Partially related: #8696