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

Avoid using BTreeMap::append #1274

Merged
merged 1 commit into from
Jan 15, 2024

Conversation

evanlinjin
Copy link
Member

Description

The implementation of BTreeMap::append is non-performant making merging changesets very slow. We use Extend::extend instead.

Refer to:
rust-lang/rust#34666 (comment)

Notes to the reviewers

This is extracted from #1172. I did this as this is a no-brainer merge whereas the rest of #1172 requires a more thoughtful review.

I discovered this when running the bitcoind examples. Loading from the database takes a very long time (if we sync from segwit activation to tip, loading LocalChain will take more than a minute). The culprit is BTreeMap::append (thank you for @LLFourn for this discovery).

Changelog notice

Fix

Checklists

All Submissions:

  • I've signed all my commits
  • I followed the contribution guidelines
  • I ran cargo fmt and cargo clippy before committing

New Features:

* [ ] I've added tests for the new feature

  • I've added docs for the new feature

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

The implementation of `BTreeMap::append` is non-performant making
merging changesets very slow. We use `Extend::extend` instead.

Refer to:
rust-lang/rust#34666 (comment)
@evanlinjin evanlinjin added the bug Something isn't working label Jan 15, 2024
@evanlinjin evanlinjin added this to the 1.0.0 milestone Jan 15, 2024
@evanlinjin evanlinjin self-assigned this Jan 15, 2024
Copy link
Contributor

@LLFourn LLFourn left a comment

Choose a reason for hiding this comment

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

ACK eb1714a

@LLFourn LLFourn merged commit b6422f7 into bitcoindevkit:master Jan 15, 2024
12 checks passed
@notmandatory notmandatory mentioned this pull request Jan 16, 2024
23 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants