Skip to content
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

Changing workflow of consuming buffered packets #23086

Closed
wants to merge 1 commit into from

Conversation

tao-stones
Copy link
Contributor

@tao-stones tao-stones commented Feb 11, 2022

Problem

For leader to prioritize transactions by total_fee/total_cu (#22820), it needs access all buffered packets as deserialized and sanitized transactions in order to get transaction CUs and total fee. In current retain_mut loop, no good place to convert all buffered unprocessed packets into transactions.

Proposal:
To replace current "process packets while looping through buffer" with following workflow:

  1. consume_buffered_packets iterate through buffered packet_batches for all unprocessed packet, produce Vec< packet_locator >, where packet_locator is (batch_index, packet_index). Therefore, the total number of packet_locator is the number of unprocessed packets in buffer;
  2. stake-weight shuffle can be optional applied to Vec<packet_locator>, so it'd be in stake shuffled order instead of FIFO;
  3. Iter through Vec<packet_locator> to packets (located by buffer[batch_index, packet_index]) into SanitizedTransactions, produce HashMap< packet_locator, SanitizedTransaction >
  4. Compute tot_fee / tot_CUs for each transaction in above HashMap, produce HashMap< fee/cu, packet_locator>
  5. Sort above HashMap by its Key, iter though to pass chunk of SanitizedTransactions to BankingStage::process_transactions().

Concerns:

  1. While the proposed flow does not introducing additional heavy ops, ( for example, each unprocessed packet in buffer still deserialized into SanitizedTransaction once per call of Consume_buffered_packets() ), it is now processing transaction-by-transaction, instead of can still process chunk of transactions to amortize account locking/loading cost and preserve entry size (thanks @sakridge )
  2. If the deserialized transactions (in step 3 above) to be cached for unprocessed packets, there are some saving from avoid re-converting packets to transaction.

Summary of Changes

Fixes #

@tao-stones tao-stones changed the title Changing workflow of conuming buffered packets Changing workflow of consuming buffered packets Feb 11, 2022
@tao-stones tao-stones added the work in progress This isn't quite right yet label Feb 16, 2022
@tao-stones
Copy link
Contributor Author

moved to #23257

@tao-stones tao-stones closed this Feb 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
work in progress This isn't quite right yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant