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

Remove database flush #575

Merged
merged 2 commits into from
Jul 4, 2022

Conversation

kafaichoi
Copy link
Contributor

@kafaichoi kafaichoi commented Mar 23, 2022

Description

This PR is to remove Database::flush. See this issue for detail #567

Notes to the reviewers

The 2nd commit is a small refactoring of adding a new private ivec_to_u32 to avoid too much code duplication. Please let me know if it's ok to include this in this PR or I should make it into a separate PR

Currently existing test cases are shared across for all Databaes implementation so I am not sure if we should add specific test cases for keyvalue(Tree) for this auto-flush behaviour?(and I feel like it's more a implementation detail). Please let me know how should I proceed for test case in this PR

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
  • I've updated CHANGELOG.md

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

@kafaichoi kafaichoi force-pushed the remove-database-flush branch from 3278ea5 to 9947611 Compare March 23, 2022 07:11
@kafaichoi kafaichoi marked this pull request as draft March 23, 2022 08:50
@kafaichoi kafaichoi force-pushed the remove-database-flush branch from 9947611 to bfaef77 Compare March 23, 2022 09:47
@kafaichoi kafaichoi force-pushed the remove-database-flush branch from bfaef77 to d107b92 Compare March 24, 2022 04:18
@notmandatory
Copy link
Member

notmandatory commented Mar 25, 2022

I think your code changes to remove flush from the Database trait and to refactor duplicate code into the ivec_to_u32 function look good.

But I'm having second thoughts on doing the auto-flush. I believe it's not meant to be used on every update since it will hurt performance and on most os/filesystems it is not needed since the os will automatically flush the data to disk if the process dies. For Android users it's reasonable to recommend using sqlite and not sled for now. In future bdk api changes that are currently being discussed the database will most likely be extracted from the Wallet and then if a user wants to use Sled on android they will be able directly call the .flush() function on Tree when they want such as when their app goes off screen or something like that. I'm going to update #567 to remove the part about auto flushing so you can remove the related code and tests from this PR.

You also need to do a cargo fmt which CI checks for. Thanks!

@kafaichoi kafaichoi force-pushed the remove-database-flush branch from d107b92 to 64a4f1b Compare March 25, 2022 02:57
@kafaichoi kafaichoi marked this pull request as ready for review March 25, 2022 02:59
@kafaichoi
Copy link
Contributor Author

kafaichoi commented Mar 25, 2022

I think your code changes to remove flush from the Database trait and to refactor duplicate code into the ivec_to_u32 function look good.

But I'm having second thoughts on doing the auto-flush. I believe it's not meant to be used on every update since it will hurt performance and on most os/filesystems it is not needed since the os will automatically flush the data to disk if the process dies. For Android users it's reasonable to recommend using sqlite and not sled for now. In future bdk api changes that are currently being discussed the database will most likely be extracted from the Wallet and then if a user wants to use Sled on android they will be able directly call the .flush() function on Tree when they want such as when their app goes off screen or something like that. I'm going to update #567 to remove the part about auto flushing so you can remove the related code and tests from this PR.

You also need to do a cargo fmt which CI checks for. Thanks!

That's very reasonable. Thank you so much for your comment. I have removed the auto-flush behaviour(and ran cargo fmt, clippy for each commit)

Copy link
Contributor

@rajarshimaitra rajarshimaitra left a comment

Choose a reason for hiding this comment

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

tACK 6dc9282

With few nits..

@rajarshimaitra
Copy link
Contributor

@notmandatory so we don't need the explicit flush any more for any of the DBs?

@notmandatory
Copy link
Member

@notmandatory so we don't need the explicit flush any more for any of the DBs?

The only database that actually implemented flush was Sled, and even for Sled it seems to only be needed for Android. That's why I suggested removing it and that mobile apps use sqlite instead. This #409 is the PR that added it, and it was to trying to fix the issues that @thunderbiscuit ran into on Android.

@afilini
Copy link
Member

afilini commented Mar 30, 2022

Maybe we should deprecate for one release before removing it? I don't know if anybody is using it, but it seems it wouldn't cost us anything to just delay the removal and it can make the transition a bit less painful for our users.

Concept ACK for the refactor but I'll take another look later to make sure the code is also good.

@notmandatory
Copy link
Member

Maybe we should deprecate for one release before removing it? I don't know if anybody is using it, but it seems it wouldn't cost us anything to just delay the removal and it can make the transition a bit less painful for our users.

Good point, I was assuming no one was using this but I think we did promise to deprecate APIs before removing them. If we do deprecate that should go in a new PR, so this one can be ready to go right after we cut the next release branch.

@kafaichoi kafaichoi force-pushed the remove-database-flush branch 2 times, most recently from 5379a34 to 0e713f8 Compare April 2, 2022 03:52
Copy link
Contributor

@rajarshimaitra rajarshimaitra left a comment

Choose a reason for hiding this comment

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

ReACK 0e713f8

@notmandatory
Copy link
Member

I've assigned this to the release 0.19.0 and added #577 to deprecate Database::flush() in 0.18.0. This PR can then be merged after we create the release/0.19.0 feature freeze branch next week.

afilini added a commit that referenced this pull request Apr 13, 2022
a111d25 Deprecate Database::flush() function (Steve Myers)

Pull request description:

  ### Description

  The Database::flush() function is only needed for the sled database on mobile, instead for mobile use the sqlite database.

  ### Notes to the reviewers

  This PR is in preparation for removing the Database::flush() function. See #575 (comment).

  After the `release/0.18.0` feature freeze branch is created then #575 should be merged.

  ### 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

  #### New Features:

  * [ ] I've added tests for the new feature
  * [ ] I've added docs for the new feature
  * [x] I've updated `CHANGELOG.md`

ACKs for top commit:
  afilini:
    ACK a111d25

Tree-SHA512: 18434dc95dbef47118a0d4fface908bdf920a7ffcef927b36bb740c15f8efcf11dea9198b364648f16f74aaec4aa18e92a3c5e925299b2f3b9d69e566f89e790
@notmandatory
Copy link
Member

Hi, please rebase to pickup changes in #596. Thanks!

@notmandatory
Copy link
Member

I had to push this PR to the next release so the team can focus on #593, and after that one you'll probably need to rebase again. But then I promise we get this one in. :-)

Copy link
Member

@danielabrozzoni danielabrozzoni left a comment

Choose a reason for hiding this comment

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

tACK b1ace3c

Copy link
Contributor

@rajarshimaitra rajarshimaitra left a comment

Choose a reason for hiding this comment

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

tACK b1ace3c

This looks ready for merge to me..

@danielabrozzoni
Copy link
Member

This PR needs rebase to fix the CHANGELOG.md conflicts and fix the CI, but then it's ready to merge 🙏🏻

@kafaichoi kafaichoi force-pushed the remove-database-flush branch from b1ace3c to e4c9919 Compare June 29, 2022 05:33
@kafaichoi kafaichoi force-pushed the remove-database-flush branch from e4c9919 to 5ff8320 Compare June 29, 2022 05:40
@danielabrozzoni
Copy link
Member

re-ACK 5ff8320

@notmandatory notmandatory merged commit 1fd62a7 into bitcoindevkit:master Jul 4, 2022
@notmandatory
Copy link
Member

Finally merged, thanks for seeing this one through!

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.

5 participants