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

[Wallet] DB optimization for faster payments #250

Merged
merged 5 commits into from Jun 10, 2023

Conversation

callebtc
Copy link
Collaborator

@callebtc callebtc commented Jun 10, 2023

Profiling results showed that calling wallet.load_proofs(), specifically the list comprehension [Proof(**dict(r)) for r in rows] in wallet/crud.py spends a lot of CPU time.

  • gets rid of most unnecessary load_proofs calls
  • skips db load if wallet.proofs is already populated in load_proofs()
  • New argument load_proofs(reload=True) forces a db reload
  • Removes most initial_balance and balance in wallet api
  • Tests: Add fixture wallet to wallet_api_test

@codecov
Copy link

codecov bot commented Jun 10, 2023

Codecov Report

Patch coverage: 83.33% and project coverage change: +0.05 🎉

Comparison is base (959cc00) 55.97% compared to head (0e7933c) 56.02%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #250      +/-   ##
==========================================
+ Coverage   55.97%   56.02%   +0.05%     
==========================================
  Files          42       42              
  Lines        3348     3343       -5     
==========================================
- Hits         1874     1873       -1     
+ Misses       1474     1470       -4     
Impacted Files Coverage Δ
cashu/mint/app.py 0.00% <ø> (ø)
cashu/wallet/api/app.py 100.00% <ø> (ø)
cashu/wallet/api/responses.py 100.00% <ø> (ø)
cashu/wallet/api/router.py 77.83% <ø> (+0.99%) ⬆️
cashu/wallet/cli/cli_helpers.py 50.00% <0.00%> (ø)
cashu/wallet/cli/cli.py 49.71% <50.00%> (+0.13%) ⬆️
cashu/wallet/helpers.py 84.76% <100.00%> (+0.14%) ⬆️
cashu/wallet/wallet.py 81.83% <100.00%> (+0.16%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@callebtc callebtc merged commit defcf7a into main Jun 10, 2023
5 checks passed
@callebtc callebtc deleted the wallet/optimize_db_for_send branch June 10, 2023 22:10
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.

None yet

1 participant