[bisq-network/bisq] Speed up deposit and transactions view loads (#5120)

Steven Barclay notifications at github.com
Wed Jan 27 04:32:15 CET 2021


<!-- 
- make yourself familiar with the CONTRIBUTING.md if you have not already (https://github.com/bisq-network/bisq/blob/master/CONTRIBUTING.md)
- make sure you follow our [coding style guidelines][https://github.com/bisq-network/style/issues)
- pick a descriptive title
- provide some meaningful PR description below
- create the PR
- in case you receive a "Change request" and/or a NACK, please react within 30 days. If not, we will close your PR and it can not be up for compensation.
- After addressing the change request, __please re-request a review!__ Otherwise we might miss your PR as we tend to only look at pull requests tagged with a "review required".
-->

This PR speeds up the loading of the deposit ("Receive funds") and transactions views (under the "Funds" tab), by adding some caches to `WalletService` and `DisputeListService`, lazily loading tx confidence tooltips for the two respective lists of items (`DepositListItem` and `TransactionsListItem`) and applying some low level optimisations to `TransactionsAwareTrade.isRelatedToTransaction`.

This also fixes a fairly minor bug in the transactions view due to a broken `TranscationsAwareTrade.isRefundPayoutTx` method, as well as a somewhat serious memory leak in the deposit view due to missing `BalanceListener` removals from the `BtcWalletService` instance.

The performance issues in these two views had started to become severe with the number of transactions and addresses now in my Bisq wallet. The deposit view was the worst, taking around 25 seconds to load, with bottlenecks in `WalletService.getTransactionConfidence` & `WalletService.getNumTxOutputsForAddress` as seen with JProfiler:

![Screenshot from 2021-01-27 02-41-06](https://user-images.githubusercontent.com/54855381/105935157-621ed900-6049-11eb-91bb-2cf83e28984e.png)

The transactions view (with 1210 rows) was taking around 5 seconds to load, with bottlenecks in `TransactionsAwareTrade.isRelatedToTransaction` & `Tooltip.<init>`:

![Screenshot from 2021-01-27 02-41-25](https://user-images.githubusercontent.com/54855381/105935191-6f3bc800-6049-11eb-8d6c-526ba9a96aa8.png)

They both seem significantly faster (in my Bisq client) with the changes in this PR, with the biggest improvement to the deposit view via the two caches added to `WalletService`. The quadratic time issue (# transactions * # past trades) causing the slowness of the transactions view is alleviated but not completely fixed by these changes. It may be possible to do more extensive lazy loading of the relevant `TransactionsListItem` fields to get further speedups.

You can view, comment on, or merge this pull request online at:

  https://github.com/bisq-network/bisq/pull/5120

-- Commit Summary --

  * Refactor: add & remove wallet listeners from the same class
  * Use cache for WalletService.getNumTxOutputsForAddress
  * Use cache for WalletService.getConfidenceForAddress
  * Optimise TransactionAwareTrade.isRelatedToTransaction
  * Add missing WalletService.removeBalanceListener to fix leak
  * Load (Deposit|Transactions)ListItem tooltips lazily

-- File Changes --

    M core/src/main/java/bisq/core/btc/wallet/BsqWalletService.java (73)
    M core/src/main/java/bisq/core/btc/wallet/BtcWalletService.java (8)
    M core/src/main/java/bisq/core/btc/wallet/WalletService.java (108)
    M core/src/main/java/bisq/core/support/dispute/DisputeListService.java (6)
    M core/src/main/java/bisq/core/support/dispute/DisputeManager.java (4)
    M desktop/src/main/java/bisq/desktop/main/funds/deposit/DepositListItem.java (80)
    M desktop/src/main/java/bisq/desktop/main/funds/transactions/TransactionAwareTrade.java (70)
    M desktop/src/main/java/bisq/desktop/main/funds/transactions/TransactionsListItem.java (79)
    M desktop/src/test/java/bisq/desktop/main/funds/transactions/TransactionAwareTradeTest.java (9)

-- Patch Links --

https://github.com/bisq-network/bisq/pull/5120.patch
https://github.com/bisq-network/bisq/pull/5120.diff

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/bisq-network/bisq/pull/5120
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20210126/20a23854/attachment.htm>


More information about the bisq-github mailing list