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

feat(btc): batch queries to improve transaction build time #200

Merged
merged 1 commit into from
May 29, 2024

Conversation

ShookLyngs
Copy link
Collaborator

@ShookLyngs ShookLyngs commented May 28, 2024

Changes

  • Add p-limit and batch queries in the sendRgbppUtxos() and TxBuilder.validateInputs() to improve transaction construction time, when querying a group of individual requests, batch up to 10 requests each time

Test

@Dawn-githup
Copy link
Contributor

Performance Comparison Data

The following table shows the time taken by the sendRgbppUtxos() function to construct a transaction on different branches. The data compares the develop branch and the feat/batch-queries branch.

With 39 Cells

Branch genBtcTransferCkbVirtualTx Time sendRgbppUtxos Time Total Time
develop 2.082s 130.531s 132.613s
develop 1.116s 111.526s 112.642s
develop 1.436s 126.264s 127.700s
PR #184 1.116s 121.187s 122.303s
PR #184 0.932s 112.381s 113.313s
PR #184 2.443s 116.837s 119.280s
feat/batch-queries 1.267s 52.193s 53.460s
feat/batch-queries 2.889s 59.937s 62.826s
feat/batch-queries 3.018s 63.788s 66.806s

Mitigating Network Fluctuations

Branch genBtcTransferCkbVirtualTx Time sendRgbppUtxos Time Total Time
develop 0.489s 50.055s 50.544s
develop 0.450s 47.480s 47.930s
develop 0.406s 55.443s 55.849s
develop 0.426s 51.939s 52.365s
develop 0.439s 50.629s 51.068s
feat/batch-queries 0.450s 22.098s 22.548s
feat/batch-queries 0.428s 27.098s 27.526s
feat/batch-queries 0.555s 22.291s 22.846s
feat/batch-queries 0.467s 28.528s 28.995s
feat/batch-queries 0.467s 28.833s 29.300s

Conclusion

From the above data, it's clear that the feat/batch-queries branch has significantly optimized the transaction construction time. When compared to the develop branch, using batch requests has drastically reduced the execution time of the sendRgbppUtxos() function.

This optimization has reduced the transaction construction time from approximately 50 seconds on the develop branch to about 22 seconds on the feat/batch-queries branch, resulting in more than a twofold performance improvement.

@Flouse Flouse added this pull request to the merge queue May 29, 2024
Merged via the queue into develop with commit f0b99c7 May 29, 2024
2 checks passed
@Flouse Flouse deleted the feat/batch-queries branch May 29, 2024 07:35
@Flouse Flouse linked an issue May 30, 2024 that may be closed by this pull request
2 tasks
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

Successfully merging this pull request may close these issues.

Building BTC TX with an address having excessive UTXOs takes forever
4 participants