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

perf: get account and access key in parallel #12982

Open
mooori opened this issue Feb 24, 2025 · 1 comment
Open

perf: get account and access key in parallel #12982

mooori opened this issue Feb 24, 2025 · 1 comment
Assignees

Comments

@mooori
Copy link
Contributor

mooori commented Feb 24, 2025

At high transaction throughput, get_account and get_access_key are two of the most expensive items in Runtime::Apply. See for example this profile of apply-range from January 2025.

These calls to get_account, get_access_key happen sequentially in verify_and_charge_transaction. Getting them in parallel should shave some time of the critical path. With TrieUpdate becoming Send + Sync [#12981], this might become achievable.

@mooori
Copy link
Contributor Author

mooori commented Feb 28, 2025

Updates:

  • Simple approach using rayon::join degrades performance.
  • A more sophisticated approach could include worker threads that send/receive work over channels. At the moment TrieUpdate is Send + Sync only for immutable references, which makes this approach impractical.
  • Another approach could be based on getting data for more than one transaction in parallel, see below. Note that this conflicts with other work (e.g. #12983).
take the first n txs such that they all have different signers
prefetch (account, access_key) for these n accounts in parallel (ok as all signers are different)
process the transactions, passing in the prefetched data
repeat until all transactions are processed

This probably degrades performance when a chunk contains many txs coming from the same signer, which will make all n small. As a mitigation, if n is mostly small for a list of transactions then this prefetching could be disabled. Should be a O(num_txs) pre-check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant