From: Steve Myers Date: Wed, 6 Apr 2022 19:39:01 +0000 (-0700) Subject: Merge bitcoindevkit/bdk#579: Faster sync by collecting esplora ureq thread handles X-Git-Tag: v0.18.0~8 X-Git-Url: http://internal-gitweb-vhost/script/%22https:/database/errors.html?a=commitdiff_plain;h=0621ca89d5f7f984b5c3281cd5b9de880342c54b;p=bdk Merge bitcoindevkit/bdk#579: Faster sync by collecting esplora ureq thread handles adef166b22d5c95006df39fd8c57574624071189 Create vector of thread handles to spawn threads (nickfarrow) Pull request description: ### Description Speeds up esplora ureq syncing. Taken from https://github.com/bitcoindevkit/bdk/pull/560 The current sync just creates a map of scripts to joinhandles which doesn't yet spawn the sync threads due to lazy evaluation. In the following `handles.map()`, the thread handles are *sequentially* evaluated and joined. With the fix, the handles are collected so that the threads spawn in parallel, and then joined ### Notes to the reviewers I had to add a `#[allow(clippy::needless_collect)]` so that it wouldn't complain about collecting and then iterating. (Perhaps clippy is partially responsible for this issue!) Tested sync performance by doing a fresh sync on an existing [gun](https://gun.fun) wallet. ``` ---- Before fix --- real0m13.121s real0m13.367s real0m13.211s ---- After fix ---- real0m5.516s real0m5.251s real0m5.594s ``` ### Checklists #### All Submissions: * [x] I've signed all my commits * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md) * [x] I ran `cargo fmt` and `cargo clippy` before committing #### Bugfixes: * [ ] This pull request breaks the existing API * [ ] I've added tests to reproduce the issue which are now passing * [ ] I'm linking the issue being fixed by this PR ACKs for top commit: notmandatory: ACK adef166b22d5c95006df39fd8c57574624071189 Tree-SHA512: 47c617117afde9b4706bfa63759bf06d1ec60ff95d8a80931e5b7e40e3293c855d2f7dac0c681173d43aecf77201a842e739b82291da09ac81909cf526a51c8d --- 0621ca89d5f7f984b5c3281cd5b9de880342c54b