Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Unapplied transaction queue performance #7686

Merged
merged 19 commits into from
Jul 29, 2019
Merged

Conversation

heifner
Copy link
Contributor

@heifner heifner commented Jul 25, 2019

Change Description

  • Applied transactions used to be removed from the unapplied transaction map when they were applied in controller::push_transaction. The removal of these applied transactions was moved into the producer_plugin during the processing of unapplied transactions. See Refactor unapplied transaction queue #7453. However, push_block transactions from other producers were not removed causing the unapplied_transaction_queue to grow with transactions that were already applied. This slowed down block production as all these transactions had to be processed to determine that they were duplicates (already applied).

Modifications:

  • Remove from the unapplied_transaction_queue all applied transactions when signaled via accepted_block.
  • Add aborted transactions into the unapplied_transaction_queue before processing the next push_block so that applied transactions can be removed via accepted_block. Otherwise, If aborted transactions are added into the unapplied_transaction_queue after push_block many/most of these transactions are actually already applied as they came in via the push_block.
  • Add forked transactions into the unapplied_transaction_queue before applying new branch so that applied transactions can be removed as applying new branch.
  • Changed to only store forked out transactions when in speculative mode.
  • Modified unapplied_transaction_queue to not store any transactions when not in speculative mode.
  • Added some tests that verify duplicates are not allowed in the unapplied_transaction_queue.

Consensus Changes

  • Consensus Changes

API Changes

  • API Changes

Documentation Additions

  • Documentation Additions

@heifner heifner requested a review from arhag July 25, 2019 19:29
unapplied_branch = std::move( branches.second );
if ( read_mode == db_read_mode::SPECULATIVE ) {
unapplied_branch = std::move( branches.second );
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is not ideal in that we add forked branches after applying the new branch which might have many of the same transactions.

heifner added 6 commits July 26, 2019 09:07
…ied_transaction_queue will determine if they should be used or not
…iously applied transactions can be added to the unapplied_transaction_queue as they are popped. This allows the transactions to be removed from the unapplied_transaction_queue as they are applied in apply_block. Before they were added after the apply which would require re-attempting to apply them when processing unapplied_tranactions
…ead of a branch_type since each forked block is added individually now
(chain.get_read_mode() != chain::db_read_mode::SPECULATIVE) ? unapplied_transaction_queue::process_mode::non_speculative :
my->_producers.empty() ? unapplied_transaction_queue::process_mode::speculative_non_producer :
unapplied_transaction_queue::process_mode::speculative_producer;
my->_unapplied_transactions.set_mode( unapplied_mode );
Copy link
Contributor

Choose a reason for hiding this comment

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

Do this in producer_plugin::plugin_initiailize. Since producer_plugin depends on chain_plugin, it is safe to get the read_mode from the controller at that point.

@heifner heifner merged commit 6781cc7 into develop Jul 29, 2019
@heifner heifner deleted the unapplied-performance branch July 29, 2019 15:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants